WebAssembly compilation error in Kotlin Multiplatform web app deployed on GitHub Pages:
- Error:
CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0 - Root cause:
sqljs.worker.jsfile contained incorrect pathlocateFile:e=>"././sql-wasm.wasm"(double./) - The SQLDelight web worker was trying to load WASM from an invalid path, causing 404 errors
Implemented robust webpack plugin with normalizeSqlJsWasmPaths function:
- Added
CopyWebpackPluginto copy all required SQL.js files (sql-wasm.wasm,sql-wasm.js,sqljs.worker.js) - Created comprehensive regex patterns to fix various path formats:
locateFilearrow functions with any variable name- Relative paths (
../,./,//) and absolute paths (/) - Both single and double quotes
- Applied normalization to both main compilation and distribution files
- All paths normalized to correct
./sql-wasm.wasmformat
✅ WebAssembly compilation error completely resolved
✅ Note Delight web app fully functional on GitHub Pages
✅ Database operations working correctly
✅ All SQL.js components loading properly