esbuild-wasm is the WebAssembly-based distribution of esbuild, a high-performance JavaScript and TypeScript bundler and minifier. It provides the core bundling and transformation capabilities of esbuild in a cross-platform WebAssembly binary, suitable for environments like web browsers, Deno, and Bun, or Node.js where a native binary might not be ideal or available. The current stable version is v0.28.0. The project maintains a rapid release cadence, often introducing new features and bug fixes, and sometimes includes deliberate backwards-incompatible changes, as highlighted in releases like v0.27.0. Its key differentiator from the primary `esbuild` package is its WebAssembly implementation, offering broader environment compatibility, though it might have slight performance variations compared to the native binary. Users should be aware of the explicit `initialize` step required for its operation.
npm install esbuild-wasmVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the esbuild-wasm service and performing a basic TypeScript transformation with minification and sourcemap generation.
Always pin the exact version of `esbuild-wasm` in your `package.json` (e.g., `"esbuild-wasm": "0.28.0"`) or use a patch-only range like `~0.28.0` to avoid unexpected breaking changes. Consult release notes before upgrading.
Ensure `await initialize({ wasmURL: '...' });` (for browsers/custom) or `await initialize({ worker: true });` (for Node.js) is called once at the start of your application lifecycle.Benchmark both `esbuild` and `esbuild-wasm` in your specific Node.js environment if performance is critical. Consider the native `esbuild` package for Node.js if maximum speed is required and cross-platform binary distribution is not a concern.
Review the release notes for new features and verify compatibility with your target browsers or runtimes. Adjust `target` options in esbuild if necessary to compile down unsupported syntax for broader compatibility.
Ensure `await initialize({ worker: true, wasmURL: '...' });` is called and successfully completes before any `build` or `transform` operations.Use `import { build } from 'esbuild-wasm';` syntax in ES module files. If targeting a browser, ensure your bundler processes `esbuild-wasm` correctly.For ESM, use `import { build } from 'esbuild-wasm';`. For CJS, use `const { build } = require('esbuild-wasm');` to destructure named exports.No dependency data recorded yet.