The wa-sqlite build produces ES6 modules, which is nice for development. But most applications should put time-consuming operations in a Worker, and support for ES6 modules in a Worker isn't universal yet. Worker code generally needs to be bundled.
Emscripten modules need to load their associated .wasm file, and the generated code for ES6 uses import.meta.url as its default location. import.meta.url is not valid outside an ES6 module, however, so the bundler has to translate this to something else. When the target context is a Worker, that something else needs to be valid in a Worker, so something like document.currentScript.src, which is the substitution my bundler chooses, causes a runtime exception.
The fix I use is to configure a bundler string replacement plug-in (@rollup/plugin-replace in my case) to replace import.meta.url with an empty string. There may be better approaches out there but this is sufficient for me so far.
The text was updated successfully, but these errors were encountered:
The wa-sqlite build produces ES6 modules, which is nice for development. But most applications should put time-consuming operations in a Worker, and support for ES6 modules in a Worker isn't universal yet. Worker code generally needs to be bundled.
Emscripten modules need to load their associated .wasm file, and the generated code for ES6 uses
import.meta.urlas its default location.import.meta.urlis not valid outside an ES6 module, however, so the bundler has to translate this to something else. When the target context is a Worker, that something else needs to be valid in a Worker, so something likedocument.currentScript.src, which is the substitution my bundler chooses, causes a runtime exception.The fix I use is to configure a bundler string replacement plug-in (@rollup/plugin-replace in my case) to replace
import.meta.urlwith an empty string. There may be better approaches out there but this is sufficient for me so far.The text was updated successfully, but these errors were encountered: