API
Other
Description
I tried getting this to deploy to worker but failed to do so.
Disclaimer: I used AI to test the deploy and generate summary below
While the compressed bundle size of the sync build (~3.5MB) is well within Cloudflare's limits, we encountered runtime blockers related to how the Emscripten module is initialized.
Blockers & Issues
1. self.location.href is Undefined
During initialization, the generated Emscripten code assumes self.location.href exists to resolve paths. In Cloudflare Workers, self.location is undefined, leading to a fatal crash:
TypeError: Cannot read properties of undefined (reading 'href')
Current Workaround: We had to globally mock location (e.g., globalThis.location = { href: 'http://localhost/' }) before importing the library, but the library should ideally check if self.location exists before accessing its properties.
2. Inability to Pass wasmBinary / WebAssembly.Module directly
In Cloudflare Workers, WebAssembly files cannot be fetched via fetch() from local paths or read from a file system. Instead, they are imported and passed into the environment as compiled WebAssembly.Module bindings.
Emscripten allows passing a pre-compiled wasmBinary (or a custom instantiateWasm function) via its Module object arguments. However, the LadybugDB.init() function exported by @ladybugdb/wasm-core/sync/index.js does not seem to expose a way to pass configuration arguments down to the underlying Emscripten module loader.
If we could do something like this, it would solve the problem:
import LadybugDB from '@ladybugdb/wasm-core/sync';
import wasmModule from './lbug_wasm.wasm'; // Cloudflare WASM binding
// Proposed API improvement
await LadybugDB.init({
wasmBinary: wasmModule
});
3. Inline WASM limits optimization (Feature Request)
Currently, the sync build fully inlines the WASM binary as a custom encoded string inside index.js. While this works, it inflates the JS parsing time. Cloudflare Workers and modern bundlers (like esbuild / Wrangler) have first-class support for importing standalone .wasm files.
It would be ideal if there was an export that provided just the JS bindings without the inlined WASM, allowing the developer to provide the .wasm file via standard edge environment bindings.
API
Other
Description
I tried getting this to deploy to worker but failed to do so.
Disclaimer: I used AI to test the deploy and generate summary below
While the compressed bundle size of the
syncbuild (~3.5MB) is well within Cloudflare's limits, we encountered runtime blockers related to how the Emscripten module is initialized.Blockers & Issues
1.
self.location.hrefis UndefinedDuring initialization, the generated Emscripten code assumes
self.location.hrefexists to resolve paths. In Cloudflare Workers,self.locationis undefined, leading to a fatal crash:Current Workaround: We had to globally mock
location(e.g.,globalThis.location = { href: 'http://localhost/' }) before importing the library, but the library should ideally check ifself.locationexists before accessing its properties.2. Inability to Pass
wasmBinary/WebAssembly.ModuledirectlyIn Cloudflare Workers, WebAssembly files cannot be fetched via
fetch()from local paths or read from a file system. Instead, they are imported and passed into the environment as compiledWebAssembly.Modulebindings.Emscripten allows passing a pre-compiled
wasmBinary(or a custominstantiateWasmfunction) via itsModuleobject arguments. However, theLadybugDB.init()function exported by@ladybugdb/wasm-core/sync/index.jsdoes not seem to expose a way to pass configuration arguments down to the underlying Emscripten module loader.If we could do something like this, it would solve the problem:
3. Inline WASM limits optimization (Feature Request)
Currently, the
syncbuild fully inlines the WASM binary as a custom encoded string insideindex.js. While this works, it inflates the JS parsing time. Cloudflare Workers and modern bundlers (likeesbuild/ Wrangler) have first-class support for importing standalone.wasmfiles.It would be ideal if there was an export that provided just the JS bindings without the inlined WASM, allowing the developer to provide the
.wasmfile via standard edge environment bindings.