browser-compat-data icon indicating copy to clipboard operation
browser-compat-data copied to clipboard

javascript.statements.import - Deno doesn't support dynamic imports for compiled bundles

Open mweichert opened this issue 3 years ago • 0 comments

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?

  1. Create a file called `include.ts' with the following contents:
const foobar = "Foo Bar"
export default foobar
  1. Create a file called foobar.ts with the following contents:
console.log(await import("file://path/to/include.ts"))
  1. Compile the bundle: deno compile ./foobar.ts

  2. 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

mweichert avatar Jun 23 '22 01:06 mweichert