{"id":22973,"library":"wasm-inliner","title":"wasm-inliner","description":"Zero-config WASM to inline JS bundler. Version 1.0.0 converts a .wasm file into a standalone JavaScript file embedding the binary as Base64, eliminating the need for fetch, CORS headers, or separate hosting. Suitable for both browser and Node.js environments, it provides a simple init function to instantiate the module. Released as a CLI tool and library, it targets small WASM modules and prioritizes simplicity over complex build integration. Differentiates from full build systems like webpack/wasm-pack by being a single-purpose, no-config utility.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","wasm","webassembly","inline","base64","bundler","cors-fix"],"install":[{"cmd":"npm install wasm-inliner","lang":"bash","label":"npm"},{"cmd":"yarn add wasm-inliner","lang":"bash","label":"yarn"},{"cmd":"pnpm add wasm-inliner","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Generated bundle exports a default async function. CJS require may work but is not officially supported; use ESM imports for browser compatibility.","wrong":"const initWasm = require('./your-file.bundle.js');","symbol":"initWasm","correct":"import initWasm from './your-file.bundle.js';"},{"note":"CLI is accessed via npx or global install; if not installed globally, run the script directly from the package.","wrong":"wasm-inliner your-file.wasm","symbol":"cli (bin)","correct":"node bin/cli.js your-file.wasm"}],"quickstart":{"code":"const initWasm = (await import('./your-file.bundle.js')).default;\nconst instance = await initWasm();\nconsole.log(instance.add(5, 10));","lang":"javascript","description":"Shows how to import the generated bundle and initialize the WASM module with a simple demo function call."},"warnings":[{"fix":"Only use for small WASM modules (<1MB). For larger files, prefer streaming compilation.","message":"Generated bundle wraps WASM as Base64; large files increase JS size significantly.","severity":"gotcha","affected_versions":"<=1.0.0"},{"fix":"Ensure initWasm() is called early and consider using Web Workers for heavy modules.","message":"The generated bundle initializes WASM synchronously within the async init function, which may block the main thread if the WASM is large.","severity":"gotcha","affected_versions":"<=1.0.0"},{"fix":"Pre-process your WASM to use simple exports/imports, or use a more comprehensive bundler like wasm-pack.","message":"This tool does not handle WASM imports (e.g., environment, memory) beyond basic WASI stub. Complex WASM modules may fail.","severity":"gotcha","affected_versions":"<=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add type=\"module\" to your script tag, or use dynamic import() in Node.","cause":"The generated bundle uses ESM syntax but is loaded in a non-module script or CommonJS context.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Verify the .wasm file is correct and re-run the inliner on it.","cause":"The .wasm file is corrupted or not a valid WebAssembly binary.","error":"Error: WebAssembly.instantiate(): expected magic word 00 61 73 6d"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}