javascript.statements.import - Deno doesn't support dynamic imports for compiled bundles
What type of issue is this?
Missing compatibility data
What information was incorrect, unhelpful, or incomplete?
According to the browser compatibility table, Deno is given a checkbox to indicate "full compatibility". However, that's not entirely true - Deno does not support dynamic imports in compiled bundles. See https://github.com/denoland/deno/issues/8655
What browsers does this problem apply to, if applicable?
Deno
What did you expect to see?
We need to add an implementation note, Deno does not support dynamic import in compiled bundles. See https://github.com/denoland/deno/issues/8655
Did you test this? If so, how?
- Create a file called `include.ts' with the following contents:
const foobar = "Foo Bar"
export default foobar
- Create a file called foobar.ts with the following contents:
console.log(await import("file://path/to/include.ts"))
-
Compile the bundle:
deno compile ./foobar.ts -
Run the bundle:
./foobar
This will throw the following error:
error: Uncaught (in promise) TypeError: Module not found
const mod = await import("file:///path/to//include.ts");
Can you link to any release notes, bugs, pull requests, or MDN pages related to this?
There have been a few different issues reported to Deno about this: https://github.com/denoland/deno/issues/8655 https://github.com/c4spar/deno-cliffy/issues/381
Do you have anything more you want to share?
Using the same code but running deno run foobar.ts works as expected.
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
MDN metadata
MDN page report details
- Query:
javascript.statements.import - Report started: 2022-06-23T01:23:45.163Z