This repository demonstrates a bug in Vite, which causes library builds with inlined .wasm
files to fail on Node.js < v16.
You must have Node.js < 16 and NPM ≥ 7. I recommend switching Node.js versions using nvm or nvm-windows.
There are two branches in this repository:
This repository contains a pre-built .wasm
file, so that you can reproduce the bug without installing the Rust toolchain:
npm install --omit=optional
npm run build
npm start
If you have installed the Rust toolchain on your system, you can reproduce the bug by building the WebAssembly module yourself:
npm install
npm run build-wasm
npm run build
npm start
$ npm start
123 + 456 = 579
$ npm start
ReferenceError: atob is not defined
at initWasm (file:///~/vite-wasm-node14-bug/dist/index.js:4:26)
at wasmInit (file:///~/vite-wasm-node14-bug/dist/index.js:22:28)
at file:///~/vite-wasm-node14-bug/dist/index.js:27:24
at file:///~/vite-wasm-node14-bug/dist/index.js:34:3
...