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 · 0 comments
Open

Document how to use import maps #159

Rhal95 opened this issue Feb 3, 2024 · 0 comments

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/emit@0.35.0/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.

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

1 participant