emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Module crashes webpack build due to use of `new URL('./', import.meta.url)`

Open seanmorris opened this issue 1 year ago • 0 comments

Emscripten packages include the following line:

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

seanmorris avatar Sep 23 '24 19:09 seanmorris