lib.wasm
- Type:
- Default:
undefined
Configure how Rslib handles .wasm modules used with the WebAssembly ESM Integration proposal syntax.
See WebAssembly for more details.
wasm.mode
- Type:
'compile' | 'preserve' - Default:
'compile'when bundle istrue,'preserve'whenbundleisfalse
Controls how .wasm modules are emitted.
'compile': Rspack parses the.wasmmodule and generates JavaScript glue code and runtime loading logic. Suitable when the library is consumed directly by a runtime such as Node.js or the browser.'preserve': Rslib keeps the.wasmimport in the output JavaScript and emits the binary as-is. This mode requires bundle to befalseand is suitable when the library is consumed by another build tool or a runtime that supports WebAssembly ESM Integration natively.
In preserve mode, the .wasm file keeps its source-relative path and original filename. output.distPath.wasm and output.filenameHash do not affect .wasm files in preserve mode.
Rslib updates JavaScript imports so they continue to point to the emitted .wasm files. It does not rewrite imports stored inside a WebAssembly binary. If a .wasm file imports JavaScript, keep the relative output path and filename of that JavaScript file unchanged.
rslib.config.ts
