-
Notifications
You must be signed in to change notification settings - Fork 55
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
How to bundle / specify wasm URL? #13
Comments
it would work correctly if you get the URL by doing const url = new URL('./foobar.wasm', import.meta.url).toString() |
I've never used Webpack and have no idea how it works. You can specify the WASM URL by passing an argument to the module factory, e.g.: import SQLiteESMFactory from '../dist/wa-sqlite.mjs';
...
const module = await SQLiteESMFactory({
locateFile(file) {
return `https://rhashimoto.github.io/wa-sqlite/dist/${file}`;
}
}); ...but I don't know whether Webpack would pick that up. Because I don't know Webpack, I don't understand your second comment - is that something you're suggesting as a user workaround, or for me to put in the package somewhere? Is the Emscripten ES6 modularization part of the problem? Building a CommonJS module is just a matter of changing Sorry, but Webpack is not even a black box to me; I don't even know what the box looks like! 😀 |
No, webpack works fine with ES6.
If you use that code snippet within the library to get the wasm file path, then webpack will realize the wasm file is an asset that needs to be written to the output folder. But looking at the code, I see that the wa-sqlite.mjs code is completely generated by emscripten so I guess you don't actually have control over that, it needs to be "fixed" on their side. Your |
Using webpack, it tries to load the WASM from a file:/// url and the wasm file is not bundled as an asset. Is it possible to specify the wasm URL or make it work with webpack in some other way?
The text was updated successfully, but these errors were encountered: