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

deno bundle not working with imports #4206

Closed
vtenfys opened this issue Mar 1, 2020 · 5 comments
Closed

deno bundle not working with imports #4206

vtenfys opened this issue Mar 1, 2020 · 5 comments
Labels
bug Something isn't working correctly

Comments

@vtenfys
Copy link

vtenfys commented Mar 1, 2020

Steps to reproduce

Create server.js with the following content:

import { serve } from "https://deno.land/std@v0.35.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
  req.respond({ body: "Hello World\n" });
}

// this is here to work around #4207
await console.log("test");

Run deno bundle server.js out.js

Run deno out.js

Expected result

The code is bundled correctly and runs

Actual result

$ deno bundle server.js out.js
Bundling "file:///path/to/server.js"
Emitting bundle to "out.js"
2.7 kB emitted.
$ deno out.js
error: Uncaught TypeError: Cannot destructure property 'd' of 'mMap.get(...)' as it is undefined.
► file:///path/to/out.js:45:17

The bundle doesn't seem to be complete - it's missing the HTTP library.

Notes

This seems related to #4031 but adding export {}; to the file doesn't fix the issue.

deno 0.35.0
v8 8.1.310
typescript 3.8.2
@ry ry added the bug Something isn't working correctly label Mar 1, 2020
@ry
Copy link
Member

ry commented Mar 1, 2020

cc @kitsonk

@nayeemrmn
Copy link
Collaborator

nayeemrmn commented Mar 1, 2020

Better repro:
a.js:

export const a = 1;

b.js:

import { a } from "./a.js";
a; // Need to reference import.

deno bundle b.js b.bundle.js && deno b.bundle.js:

Bundling "file:///mnt/c/Users/Nayeem/projects/deno/b.js"
Emitting bundle to "b.bundle.js"
2.4 kB emitted.
error: Uncaught TypeError: Cannot destructure property 'd' of 'mMap.get(...)' as it is undefined.
► file:///mnt/c/Users/Nayeem/projects/deno/b.bundle.js:45:17

45         const { d } = mMap.get(id);
                   ^

    at enq (file:///mnt/c/Users/Nayeem/projects/deno/b.bundle.js:45:17)
    at enq (file:///mnt/c/Users/Nayeem/projects/deno/b.bundle.js:47:9)
    at __inst_s (file:///mnt/c/Users/Nayeem/projects/deno/b.bundle.js:95:5)
    at file:///mnt/c/Users/Nayeem/projects/deno/b.bundle.js:117:1

@vtenfys vtenfys changed the title deno bundle not working with official example deno bundle not working with imports Mar 1, 2020
@kitsonk
Copy link
Contributor

kitsonk commented Mar 1, 2020

Taking a look... 😕

@kitsonk
Copy link
Contributor

kitsonk commented Mar 2, 2020

This is related analysis of dependencies in JavaScript (related to #4040 and #4120)... Fix incoming.

@kitsonk
Copy link
Contributor

kitsonk commented Mar 4, 2020

I think this was closed by 83d902a. While it contains a top level for...await, there is #4207 for tracking that. There was an issue with bundling JavaScript files even without a top level for...await.

@ry ry closed this as completed Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants