{"id":22922,"library":"vite-plugin-wasm","title":"Vite Plugin WASM","description":"Adds WebAssembly ESM integration (aka Webpack's asyncWebAssembly) to Vite and supports wasm-pack generated modules. Current stable version is 3.6.0, compatible with Vite 2.x through 8.x. Releases follow regular cadence with breaking changes aligned with Vite major versions. Key differentiators: enables importing .wasm files as ES modules, handles wasm-pack output, and works in Web Workers. Requires vite-plugin-top-level-await for browser targets below esnext. Ships TypeScript declarations.","status":"active","version":"3.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/Menci/vite-plugin-wasm","tags":["javascript","vite","plugin","wasm","webassembly","wasm-pack","es-modules","modules","typescript"],"install":[{"cmd":"npm install vite-plugin-wasm","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-wasm","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-wasm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin works with Vite 2.x to 8.x","package":"vite","optional":false},{"reason":"recommended companion plugin for non-esnext build targets to handle top-level await in WASM modules","package":"vite-plugin-top-level-await","optional":true}],"imports":[{"note":"ESM-only package; use dynamic import for CommonJS","wrong":"const wasm = require('vite-plugin-wasm')","symbol":"default","correct":"import wasm from 'vite-plugin-wasm'"},{"note":"Default export, not named. Plugin function is the default export.","wrong":"import { wasm } from 'vite-plugin-wasm'","symbol":"wasm","correct":"import wasm from 'vite-plugin-wasm'"},{"note":"TypeScript only; use type import to avoid runtime issues","wrong":"import { VitePluginWasmOptions } from 'vite-plugin-wasm'","symbol":"VitePluginWasmOptions","correct":"import type { VitePluginWasmOptions } from 'vite-plugin-wasm'"}],"quickstart":{"code":"import wasm from 'vite-plugin-wasm';\nimport topLevelAwait from 'vite-plugin-top-level-await';\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  plugins: [\n    wasm(),\n    topLevelAwait()\n  ]\n});","lang":"typescript","description":"Shows basic setup with required companion plugin for top-level await support."},"warnings":[{"fix":"Use asterisk import (import * as wasmModule from './module.wasm') with type assertion.","message":"TypeScript typing is broken: importing .wasm files still gets Vite's built-in typing, not the plugin's custom module declaration.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Vite to >=3.0.3 or plugin to >=3.1.0, or exclude the offending package from optimizeDeps.","message":"ESBuild errors with .wasm files in Vite < 3.0.3: 'No loader is configured for \".wasm\" files' appears when importing WASM from node_modules.","severity":"breaking","affected_versions":"<3.1.0"},{"fix":"Add wasm() and topLevelAwait() to worker.plugins in Vite config, and don't set worker.format to 'es' for Firefox support.","message":"Web Workers require manual addition of plugin to worker.plugins.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Remove worker.format configuration; rely on vite-plugin-top-level-await for compatibility.","message":"worker.format: 'es' support removed in vite-plugin-top-level-await >= 1.3.0; leaving format default (module) is fine.","severity":"deprecated","affected_versions":">=1.3.0 of vite-plugin-top-level-await"}],"env_vars":null,"search_vec":"'2':29 '3.6.0':25 '8':32 'add':4 'aka':8 'align':41 'asyncwebassembl':11 'await':71 'break':39 'browser':73 'cadenc':37 'chang':40 'compat':26 'current':21 'declar':79 'differenti':47 'enabl':48 'es':53,89 'es-modul':88 'esm':6 'esnext':76 'file':51 'follow':35 'generat':19 'handl':55 'import':49 'integr':7 'javascript':80 'key':46 'level':70 'major':44 'modul':20,54,90,91 'output':59 'pack':18,58,87 'plugin':2,68,82 'regular':36 'releas':34 'requir':65 'ship':77 'stabl':22 'support':15 'target':74 'top':69 'typescript':78,92 'version':23,45 'vite':1,13,28,43,67,81 'vite-plugin-top-level-await':66 'wasm':3,17,50,57,83,86 'wasm-pack':16,56,85 'web':63 'webassembl':5,84 'webpack':9 'work':61 'worker':64 'x':30,33","created_at":"2026-04-27T17:07:47.891299+00:00","updated_at":"2026-04-27T17:07:47.891299+00:00","problems":[{"fix":"Upgrade Vite to >=3.0.3 or plugin to >=3.1.0, or add 'optimizeDeps.exclude: [\"somepackage\"]' to vite.config.","cause":"Vite version below 3.0.3 or plugin version below 3.1.0 does not handle WASM imports from node_modules.","error":"No loader is configured for \".wasm\" files: node_modules/somepackage/somefile.wasm"},{"fix":"Add topLevelAwait() plugin to Vite config.","cause":"Omitting vite-plugin-top-level-await when build.target is not 'esnext'.","error":"Top-level await is not available in the configured target environment"},{"fix":"Use import or dynamic import() instead of require().","cause":"Package is ESM-only; require() is not supported.","error":"Cannot find module 'vite-plugin-wasm' when using require()"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Menci/vite-plugin-wasm","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-plugin-wasm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}