Registry / web-framework / vite-plugin-wasm-pack

vite-plugin-wasm-pack

JSON →
library0.1.12jsnpmunverified

Vite plugin (v0.1.12) that integrates Rust WebAssembly crates built with wasm-pack into Vite projects. It automatically serves local wasm-pack crates and supports npm-published wasm-pack packages (target web). The plugin wires up Vite's dev server and build pipeline to handle .wasm files and JavaScript glue code. It requires wasm-pack to be installed separately and the crate must be built beforehand. Compared to alternatives like vite-plugin-wasm, this plugin is specifically designed for wasm-pack output and offers simpler configuration for local crates.

npm install vite-plugin-wasm-pack
INSTALL
IMPORT
SIG · VITE-PLUGIN-WASM-P
V
vite-plugin-wasm-pack
web-frameworkjavascriptv0.1.12
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (wasmPack)
import wasmPack from 'vite-plugin-wasm-pack'
const wasmPack = require('vite-plugin-wasm-pack')
ESM default export. CommonJS require may work but is not recommended.
vite config usage
import wasmPack from 'vite-plugin-wasm-pack'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [wasmPack('./crate')] })
import { wasmPack } from 'vite-plugin-wasm-pack'
The plugin is a default export, not a named export.
TypeScript types
import wasmPack from 'vite-plugin-wasm-pack'
Package ships TypeScript types. No separate type import needed.

Shows how to configure Vite with a local wasm-pack crate and use its exports.

// vite.config.ts import { defineConfig } from 'vite'; import wasmPack from 'vite-plugin-wasm-pack'; export default defineConfig({ plugins: [wasmPack('./my-crate')] }); // After building the crate with: // wasm-pack build ./my-crate --target web // In your frontend code: import init, { greet } from './my-crate'; async function main() { await init(); greet('World'); } main();
Debug
Known issues
gotchaCrate must be built manually with wasm-pack before starting the dev server.
fix
Run 'wasm-pack build ./my-crate --target web' before 'vite' or 'vite build'.
affects: >=0.0.0
gotchaOnly packages built with --target web are supported. npm packages built with other targets will not work.
fix
Rebuild the package with '--target web' or use a different plugin.
affects: >=0.0.0
gotchaVite may cache your wasm module. After modifying Rust code, the old module might be served.
fix
Clear Vite cache by deleting node_modules/.vite or restarting the dev server.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module './my-crate' or its corresponding type declarations.
The wasm-pack output has not been built or the path is incorrect.
fix
Run 'wasm-pack build ./my-crate --target web' and ensure the path matches.
Failed to parse source map: .../my-crate/pkg/my_crate.js
The wasm-pack generated source map may be incomplete or missing.
fix
Disable source maps in Vite config or ignore the error; it is non-blocking.
[vite] Internal server error: wasm-pack plugin: crate not found
The crate path passed to wasmPack() is incorrect or does not contain a Cargo.toml.
fix
Provide an absolute or relative path to the crate directory containing Cargo.toml.
Upgrade
Version history
0.1.12latest on npm
Audit
Dependencies
viterequiredPeer dependency: works as a Vite plugin
Agent activity
10 hits · last 30 days
node
6
OpenAI (training)
2
Amazon
1
Resources
vite-plugin-wasm-pack — npm install vite-plugin-wasm-pack · libregistry