Create server.js with the following content:
import { serve } from "https://deno.land/[email protected]/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
The code is bundled correctly and runs
$ 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.
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
cc @kitsonk
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
Taking a look... 😕
This is related analysis of dependencies in JavaScript (related to #4040 and #4120)... Fix incoming.
I think this was closed by 83d902a7803adb0c69fe2c98e692a50dae446db9. 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.
Most helpful comment
I think this was closed by 83d902a7803adb0c69fe2c98e692a50dae446db9. 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 levelfor...await.