{"id":25425,"library":"esbuild-plugin-wasm-pack","title":"esbuild-plugin-wasm-pack","description":"esbuild-plugin-wasm-pack is an esbuild plugin that runs wasm-pack before each build to compile Rust/Wasm crates. Version 1.1.0 is the latest stable release. It integrates esbuild with the wasm-pack toolchain, automatically generating WebAssembly modules during the bundling process. Key differentiators include seamless integration with esbuild's plugin system, TypeScript support via generated .d.ts files, and full configuration parity with wasm-pack build arguments. It requires Node.js >=0.10.0, esbuild >=0.11.15, Rust/Cargo, and wasm-pack to be installed. The plugin is actively maintained on GitHub and distributed via npm.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/Tschrock/esbuild-plugin-wasm-pack","tags":["javascript","wasm","wasm-pack","webassembly","esbuild","plugin","esbuild-plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-wasm-pack","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-wasm-pack","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-wasm-pack","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; the plugin hooks into esbuild's build process.","package":"esbuild","optional":false}],"imports":[{"note":"The plugin is a CommonJS module that exports a function; default import is safe in ES or CJS contexts. Use require if not using ESM.","wrong":"const wasmpack = require('esbuild-plugin-wasm-pack')","symbol":"default (wasmpack)","correct":"import wasmpack from 'esbuild-plugin-wasm-pack'"},{"note":"Types are shipped and can be imported from the package directly.","wrong":"","symbol":"type imports","correct":"import type { WasmPackOptions } from 'esbuild-plugin-wasm-pack'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport wasmpack from 'esbuild-plugin-wasm-pack';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    wasmpack({\n      path: './rust-crate',   // path to your Rust crate\n      target: 'bundler',\n      profile: 'release',\n      logLevel: 'warn',\n    }),\n  ],\n});","lang":"typescript","description":"Demonstrates how to use esbuild-plugin-wasm-pack to build a Rust WebAssembly crate during an esbuild build."},"warnings":[{"fix":"Ensure wasm-pack is installed globally (e.g., cargo install wasm-pack) and verify with 'which wasm-pack' or set WASM_PACK_PATH environment variable.","message":"wasm-pack must be installed and available in PATH, otherwise the plugin will fail silently or throw an obscure error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using wasm-pack programmatically or running it as a separate build step for large crates.","message":"The plugin runs wasm-pack synchronously via execSync, which can block the event loop during builds.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the functional import: import wasmpack from 'esbuild-plugin-wasm-pack' and call it as a function with options.","message":"As of version 1.0.0, the plugin changed from a class-based API to a function-based API. Users upgrading from 0.x may need to adjust their usage.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use Node.js >=12 (or current LTS) to ensure compatibility with esbuild and modern JavaScript features.","message":"The 'node' engine requirement is >=0.10.0, which is extremely outdated. There is a risk of using unsupported Node.js versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Double-check the 'path' option points to a directory with a Cargo.toml file.","message":"The plugin does not validate that the specified 'path' contains a valid Cargo.toml. Misconfiguration leads to confusing errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install wasm-pack globally: 'cargo install wasm-pack'. Alternatively, set the 'wasmPackPath' option or WASM_PACK_PATH environment variable to the executable's path.","cause":"wasm-pack is not installed or not in PATH.","error":"Error: spawn wasm-pack ENOENT"},{"fix":"Use 'import wasmpack from \"esbuild-plugin-wasm-pack\"' (default import) or 'const wasmpack = require(\"esbuild-plugin-wasm-pack\")'. Do not destructure.","cause":"Incorrect import style; the plugin exports a function, not an object.","error":"TypeError: wasmpack is not a function"},{"fix":"Check the Rust crate for compilation errors. Ensure all dependencies are present. Run 'wasm-pack build' in the crate directory to see detailed output.","cause":"wasm-pack encountered an error while building the Rust crate.","error":"wasm-pack build failed with exit code 101"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}