Loaders: resolved vs. referencing URL #140
Description
The current experimental module resolve
loader hook returns an Object { format, url }
resulting in a mapping of the (original) referencing URL to a new resolved URL which satisfies idempotency requirements for subsequent calls to the same (original) host resolved URL.
While this is sufficient for many cases, sometimes it resolved URL's merely point to cached files which are generated for temporary use. In such cases, the specifiers inside those files may be invalid, that is to say they too must first be resolved relative to the (original) referencing URL which might follow the same resolution path or more importantly may resolve through a completely different path.
One way to over come this is to let the custom loaders handle it, which imho from all my attempts very degrading to performance, reliability and maybe even security.
The other recommendation is to allow resolvers to return Object { format, url, mapped? }
which adds an optional mapped
field that if present and is true then resolving within the module itself would be relative to the (original) referencing URL instead of the actual resolved URL.
A closing thought to ponder, while static imports can be rewritten (somewhat of pain), dynamic imports bring about a whole level of complexity when left to be handled by custom loaders (compared to the recommended solution).