-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Closed
Copy link
Labels
clirelated to cli/ dirrelated to cli/ dirsuggestionsuggestions for new features (yet to be agreed)suggestions for new features (yet to be agreed)
Description
When a module containing a relative dynamic import is included in a bundle, currently we don't make any modifications to the specifier. The exact resolution should be preserved by hardcoding the original referrer.
// In a module https://example.com/foo.ts:
await import(specifier);
// when bundled should first and foremost be transformed to:
await import(new URL(specifier, import.meta.url));
// which should then go through our existing `import.meta` hardcoding, making it:
const importMeta = {
url: "https://example.com/foo.ts",
main: false,
};
await import(new URL("./foo.ts", importMeta.url).href);
However, trying to use the URL
global here is vulnerable and doesn't provide import map resolution.
We should wait for something like import.meta.resolve()
before fixing this. Any complications are deferred naturally to our handling of that.
// In a module https://example.com/foo.ts:
await import(specifier);
// when bundled should first and foremost be transformed to:
await import(import.meta.resolve(specifier));
// which should then go through our existing `import.meta` hardcoding, making it:
const importMeta = {
url: "https://example.com/foo.ts",
main: false,
resolve(specifier) {
// Inlined generic resolution, relative to `importMeta.url`, containing a hardcoded import map.
}
};
await import(importMeta.resolve(specifier));
Ref #7296, whatwg/html#5572.
cc @guybedford
Metadata
Metadata
Assignees
Labels
clirelated to cli/ dirrelated to cli/ dirsuggestionsuggestions for new features (yet to be agreed)suggestions for new features (yet to be agreed)