-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EXPORT_ES6 should add leading ./ to WebAssembly path #19066
Comments
Sounds like a good idea. I'm also looked at adding tests here in the emscripten repo for various bundlers. I did the first one in #18969 but I plan to do more. |
Excellent! There is also the problem where esbuild chokes on this: scriptDirectory = require('url').fileURLToPath(new URL('./', import.meta.url)); // includes trailing slash but I'm not really sure if there's any way around that (and in any case you can avoid it by adding |
Actually Webpack doesn't seem to like that line above ( |
Right, so the issue with
The obvious solution is to build a web-only module (e.g. Failing that, maybe there is another way to get the script directory in Node without triggering Webpack's bogus module resolution, but I'm not totally sure what it is... |
This is what Webpack will do to |
Also note that the proposed implementation for |
That sounds like a weird choice to me TBH because relative URLs are unambiguous and are specified to behave in the same way whether |
Indeed! I am not really sure what the esbuild maintainer means by "unambiguous" in this case, but perhaps it has something to do with thinking that a bare relative path is a "module"... |
To be fair, I've been watching that PR & the original issue for a long while (you might see my comments there) and there hasn't been any change in many months now, so I'd rather wait for any updates from the maintainer before committing to any changes on the Emscripten side. I suspect they currently just don't have time to work on this feature, so applying workarounds that might or might not be necessary when the PR is finished seems a bit premature. |
Sounds good - I will close this issue, because for the moment, you can either copy the |
esbuild is finally getting around to supporting
import.meta.url
in the same way that other bundlers do, which will allow modules compiled withEXPORT_ES6
to find their corresponding WebAssembly files properly when bundling...... except that it doesn't quite work, because the currently proposed implementation expects the path of a resource referenced with
new URL(..., import.meta.url)
to begin with./
or../
to avoid ambiguity.For compatibility with this, it may be useful (as long as it doesn't hurt anyone else) to add this leading
./
when outputting that path withEXPORT_ES6
, otherwise it will continue to be difficult to use Emscripten-compiled modules with esbuild.The text was updated successfully, but these errors were encountered: