How can I load a wasm file under node_modules as asset in snowpack?(for sql.js)

518 views Asked by At

I want to use the sql.js library, which uses wasm to provide sql support in browser.

To use this library in a React project, sql.js recommends using craco.js to extend the webpack config in CRA and use the file-loader package of webpack to fetch the wasm file from the node_modules directory.

You can look at the official react demo code for sql.js here. The specific lines of code: import wasm file, use file

Snowpack suggests to use the browser's native WebAssembly and fetch APIs, but sql.js seems to require a uri for the wasm file. How can I achieve that in snowpack?

PS: sql.js uses emscripten to compile SQLite to wasm

0

There are 0 answers