emscripten-core / emscripten-core/emscripten
Module crashes webpack build due to use of `new URL('./', import.meta.url)`
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Emscripten packages include the following line:
```javascript
scriptDirectory = require('url').fileURLToPath(new URL("./", import.meta.url));
```
This is completely valid javascript. The issue is that when Webpack tries to bundle it, the bundler will attempt to resolve the URL, due to the `new URL("./", import.meta.url)` which will crash the bundler when it finds a directory.
This is a relatively longstanding bug in webpack, and since other behaviors depend in it, there is no fix on the horizion.
https://github.com/webpack/webpack/issues/16878
Some very prominent projects are affected by this, and as there is no fix in sight, I'd really like to just make Emscripten webpack-compatible by default, so long as we're not bending over backward for it.
https://github.com/electric-sql/pglite/issues/328
I've submitted the following pull request that changes the notation to something equivalent that Webpack will ignore:
https://github.com/emscripten-core/emscripten/pull/22605
Contributor guide
Assessment
This issue has not been assessed yet.