Skip to content
This repository has been archived by the owner on Nov 13, 2022. It is now read-only.

dynamic imports urls are not resolved correctly on browsers which support dynamic imports natively #5

Open
LarsDenBakker opened this issue Mar 15, 2020 · 0 comments · May be fixed by #7

Comments

@LarsDenBakker
Copy link

LarsDenBakker commented Mar 15, 2020

When a browser supports dynamic imports it is shimmed like this:

self[importFunctionName] = new Function('u', `return import(u)`);

This is incorrect because the URL is no longer resolved relative to importing module, but relative to the dynamic import polyfill file instead. This is a problem for example loading modules from different on a CDN.

Ideally we would have access to the importing module location, so that urls can be resolved transparently relative to the importing module with new URL(id, importer), then there is no need for setting a module directory.

Without that, I think the urls in native dynamic imports should be resolved relative to the module directory so that the behaviour is identical to the behaviour of the polyfill.

@LarsDenBakker LarsDenBakker linked a pull request Mar 15, 2020 that will close this issue
@LarsDenBakker LarsDenBakker changed the title dynamic imports urls are not resolved correctly on browsers which support dynamic imports antively dynamic imports urls are not resolved correctly on browsers which support dynamic imports natively Mar 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant