{"id":19065485,"url":"https://github.com/menci/vite-plugin-wasm","last_synced_at":"2025-05-14T19:05:05.761Z","repository":{"id":37817416,"uuid":"465786587","full_name":"Menci/vite-plugin-wasm","owner":"Menci","description":"Add WebAssembly ESM integration (aka. Webpack's `asyncWebAssembly`) to Vite and support `wasm-pack` generated modules.","archived":false,"fork":false,"pushed_at":"2024-12-20T03:53:17.000Z","size":490,"stargazers_count":343,"open_issues_count":13,"forks_count":19,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-14T22:09:23.219Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Menci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-03T15:57:15.000Z","updated_at":"2025-04-11T04:39:27.000Z","dependencies_parsed_at":"2023-02-19T00:31:14.918Z","dependency_job_id":"f0c3ee7f-1347-4901-aa7d-0e75f7c08988","html_url":"https://github.com/Menci/vite-plugin-wasm","commit_stats":{"total_commits":40,"total_committers":4,"mean_commits":10.0,"dds":0.07499999999999996,"last_synced_commit":"f9ba5465d7728e4a42342a69f86834bcaa9ee8c4"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fvite-plugin-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fvite-plugin-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fvite-plugin-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fvite-plugin-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Menci","download_url":"https://codeload.github.com/Menci/vite-plugin-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968914,"owners_count":21191162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T00:50:26.411Z","updated_at":"2025-04-14T22:09:27.646Z","avatar_url":"https://github.com/Menci.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vite-plugin-wasm\n\n[![Test Status](https://img.shields.io/github/actions/workflow/status/Menci/vite-plugin-wasm/test.yaml?branch=main\u0026style=flat-square)](https://github.com/Menci/vite-plugin-wasm/actions?query=workflow%3ATest)\n[![npm](https://img.shields.io/npm/v/vite-plugin-wasm?style=flat-square)](https://www.npmjs.com/package/vite-plugin-wasm)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![License](https://img.shields.io/github/license/Menci/vite-plugin-wasm?style=flat-square)](LICENSE)\n\nAdd WebAssembly ESM integration (aka. Webpack's `asyncWebAssembly`) to Vite and support `wasm-pack` generated modules.\n\n## Installation\n\nThis plugin supports from Vite 2.x to 6.x. Just install it:\n\n```bash\nyarn add -D vite-plugin-wasm\n```\n\n## Usage\n\nYou also need the `vite-plugin-top-level-await` plugin unless you target very modern browsers only (i.e. set `build.target` to `esnext`).\n\n```typescript\nimport wasm from \"vite-plugin-wasm\";\nimport topLevelAwait from \"vite-plugin-top-level-await\";\n\nexport default defineConfig({\n  plugins: [\n    wasm(),\n    topLevelAwait()\n  ]\n});\n```\n\nIf you are getting ESBuild errors of WASM files (In the format `No loader is configured for \".wasm\" files: node_modules/somepackage/somefile.wasm`) with **Vite \u003c 3.0.3**, please upgrade your Vite to **\u003e= 3.0.3 or upgrade this plugin to \u003e= 3.1.0**. A workaround is adding the corresponding imported module within `node_modules` to `optimizeDeps.exclude`, e.g.:\n\n```typescript\nexport default defineConfig({\n  optimizeDeps: {\n    exclude: [\n      \"@syntect/wasm\"\n    ]\n  }\n});\n```\n\n## Web Worker\n\nTo use this plugin in Web Workers. Add it (and `vite-plugin-top-level-await` if necessary) to `worker.plugins`. To support Firefox, don't use ES workers. leave `worker.format` default and use `vite-plugin-top-level-await` \u003e= 1.4.0 (see also [here](https://github.com/Menci/vite-plugin-top-level-await#workers)):\n\n```ts\nexport default defineConfig({\n  plugins: [\n    wasm(),\n    topLevelAwait()\n  ],\n  worker: {\n    // Not needed with vite-plugin-top-level-await \u003e= 1.3.0\n    // format: \"es\",\n    plugins: [\n      wasm(),\n      topLevelAwait()\n    ]\n  }\n});\n```\n\n# Notes\n\nTypeScript typing is broken. Since we can't declare a module with `Record\u003cstring, any\u003e` as its named export map. Your `import ... from \"./module.wasm\";` will still got Vite's bulit-in typing, but the transformed code is fine. So just use an asterisk import `import * as wasmModule from \"./module.wasm\"` and type assertion (you have typing for your WASM files, right?).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmenci%2Fvite-plugin-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmenci%2Fvite-plugin-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmenci%2Fvite-plugin-wasm/lists"}