Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to use import maps #159

Open
Rhal95 opened this issue Feb 3, 2024 · 1 comment
Open

Document how to use import maps #159

Rhal95 opened this issue Feb 3, 2024 · 1 comment

Comments

@Rhal95
Copy link

Rhal95 commented Feb 3, 2024

Document how to bundle with import maps.

When I follow the readme and write a simple script to bundle my application I get something like this:

import { bundle } from "https://deno.land/x/[email protected]/mod.ts";

const url: string = import.meta.resolve('./main.ts');
const { code } = await bundle(url);

// write 'code' into a file 

Which works as long as we are not using import maps in the application.

If you try to use import maps you will just get a cryptic error:

error: Uncaught (in promise) Error: Unable to output during bundling.
      const ret = new Error(getStringFromWasm0(arg0, arg1));

Passing the used import map into the bundle() function will solve this:
const { code } = await bundle(url, {importMap: './deno.json'});

This should be documented in the readme. I just spend an hour trying to figure out why my build suddenly stopped working after updating a couple of dependencies and introducing import maps.

@yacinehmito
Copy link
Contributor

I am unsure about documenting how to use import maps specifically. The documentation is already very sparse.
I think what should be made clearer is that it is a relatively low-level library. It does not come with Deno's bells and whistles. A user should not expect the library to automatically resolve Deno configuration files, as those are for the CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants