Let's say I have a module on a CDN: https://unpkg.com/lit-element/lit-element.js and from this module I do a dynamic import: import('./foo.js')
With native dynamic imports it will import https://unpkg.com/lit-element/foo.js. With this polyfill it will import window.location + moduleDirectory + 'foo.js' which is incorrect.
Instead the import should be resolved relative to the importing module, the polyfill could accept a second (optional) parameter for that. This does require bundlers to implement this as well, I filed https://github.com/rollup/rollup/issues/3444 on rollup side for that.
Hey @LarsDenBakker, where did you get to on this? I have the same problem with this polyfill when loading modules from a cdn. Any help would be greatly appreciated.
Let's say I have a module on a CDN:
https://unpkg.com/lit-element/lit-element.js
and from this module I do a dynamic import:import('./foo.js')
With native dynamic imports it will import
https://unpkg.com/lit-element/foo.js
. With this polyfill it will importwindow.location + moduleDirectory + 'foo.js'
which is incorrect.Instead the import should be resolved relative to the importing module, the polyfill could accept a second (optional) parameter for that. This does require bundlers to implement this as well, I filed https://github.com/rollup/rollup/issues/3444 on rollup side for that.