esbuild plugin (v0.2.7) for importing WebAssembly (.wasm) and WebAssembly text format (.wat) files. Resolves imports to a default Uint8Array export suitable for WebAssembly.instantiate()/compile(). Ships TypeScript types. Differentiators: supports .wat compilation via wabt.js with caching, optional binaryen inlining optimization, configurable loader (binary/base64/file), experimental bundling of multiple wat/wasm files using import syntax. Lightweight alternative to full-featured bundler plugins like wasm-pack.
npm install esbuild-plugin-watNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates esbuild configuration with watPlugin to import .wat files as Uint8Array, showing default options and commented alternatives.
Use: const { instance } = await WebAssembly.instantiate(wasm);Use 'binary' (default) to inline the binary; use 'file' only if you control the static file serving and path resolution.
Switch to ESM imports: import watPlugin from 'esbuild-plugin-wat'
Create a fresh options object per build call: watPlugin({ ... })Test thoroughly with your .wat files; fall back to multiple separate .wasm imports if issues arise.
Use import statement or set { "type": "module" } in package.json.Use watPlugin() (a function call) in plugins array, not just watPlugin reference.
Ensure the default export is used as-is: const wasm = await import('./file.wat'); WebAssembly.instantiate(wasm.default);