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

Import-maps does not work in dynamic imports import() #18982

Closed
tani opened this issue May 4, 2023 · 0 comments
Closed

Import-maps does not work in dynamic imports import() #18982

tani opened this issue May 4, 2023 · 0 comments

Comments

@tani
Copy link

tani commented May 4, 2023

Import map is an option to rewrite the module path to another.
For instance, By "npm:" : "https://esm.sh/", the runtime changes the path "npm:diff" to "https://esm.sh".

parent.ts + import-maps
|---------------------(import)
+-- child.ts
     |----------------(import)
     +-- `npm:diff` ===> `https://esm.sh/diff`

I noticed that the import-map is unavailable in the following situation.

parent.ts + import-maps
|---------------------(dynamic import)
+-- child.ts
     |----------------(import)
     +-- `npm:diff` =x=> `https://esm.sh/diff`

Expected behavior

According to the specification, "Only one import map is processed per Document.".
The parent module shares the document context with the child one.
Thus, the parent module should share the import-maps with the child one too.

Reproducible steps

{
   "imports": {
     "npm:": "https://esm.sh/"
   }
}
await import(new URL('child.ts', import.meta.url))
import * as diff from "npm:diff"
diff;

Significance of this issue

#15826 , the developers have no plan to support "npm:" modules in the dynamic import.
However, we sometime need to dynamically import the third-party module depending the "npm:" module.
Further, we have no way to know which module has no dependency to "npm:" module in advance.
Therefore, to avoid "npm:" module temporally, we need to define such a rule.

Related issues

@tani tani closed this as completed May 4, 2023
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