With library.type: module, import.meta.url shouldn't be replaced with static string
See original GitHub issueBug report
What is the current behavior?
When bundling a library with type: 'module'
, source references to import.meta.url
are replaced with static file:///...
strings.
As a result, operations on query parameters like the example from the MDN page on import.meta
do not work.
If the current behavior is a bug, please provide the steps to reproduce.
Observable at https://immers-space.github.io/immers-client/
<script type="module" src="https://unpkg.com/immers-client/dist/destination.bundle.js?position=top-right&title=immers-client%20Documentation"></script>
// destination.bundle.js source
scriptArgs = Object.fromEntries(new URL(import.meta.url).searchParams)
// destination.bundle.js output
P = Object.fromEntries(new URL("file:///home/username/git/immers-client/oneLiner.js").searchParams)
scriptArgs
is always empty because the import.meta.url
is replaced with the build-time filepath
Webpack config (45 lines): https://github.com/immers-space/immers-client/blob/main/webpack.common.js
What is the expected behavior?
import.meta.url
appears unmodified in the output and I am able to retrieve query parameters from it at runtime
Other relevant information: webpack version: 5.64.2 Node.js version: v16.13.0 Operating System: Ubuntu 21.10 Additional tools: none
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top GitHub Comments
Yep, we should improve this
yep, this can be closed