{"id":13417192,"url":"https://github.com/nshen/vite-plugin-wasm-pack","last_synced_at":"2025-10-24T08:53:13.538Z","repository":{"id":39925591,"uuid":"379446774","full_name":"nshen/vite-plugin-wasm-pack","owner":"nshen","description":"🦀 Vite plugin for rust wasm-pack ","archived":false,"fork":false,"pushed_at":"2024-07-31T08:08:46.000Z","size":139,"stargazers_count":241,"open_issues_count":23,"forks_count":37,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-03T09:25:43.643Z","etag":null,"topics":["rust","rust-web","vite-plugin","vitejs","wasm-bindgen","wasm-pack","webassembly"],"latest_commit_sha":null,"homepage":"","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/nshen.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":"2021-06-23T01:38:31.000Z","updated_at":"2024-12-28T07:21:00.000Z","dependencies_parsed_at":"2024-01-07T18:04:14.220Z","dependency_job_id":"68345cef-9e24-4f78-b276-6c8eb9288045","html_url":"https://github.com/nshen/vite-plugin-wasm-pack","commit_stats":{"total_commits":49,"total_committers":8,"mean_commits":6.125,"dds":"0.24489795918367352","last_synced_commit":"5e626b9d387b9e9df87712479df2eb5110af02f7"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshen%2Fvite-plugin-wasm-pack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshen%2Fvite-plugin-wasm-pack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshen%2Fvite-plugin-wasm-pack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshen%2Fvite-plugin-wasm-pack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nshen","download_url":"https://codeload.github.com/nshen/vite-plugin-wasm-pack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248609575,"owners_count":21132916,"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":["rust","rust-web","vite-plugin","vitejs","wasm-bindgen","wasm-pack","webassembly"],"created_at":"2024-07-30T22:00:33.683Z","updated_at":"2025-10-24T08:53:08.505Z","avatar_url":"https://github.com/nshen.png","language":"TypeScript","funding_links":[],"categories":["Plugins","TypeScript"],"sub_categories":["Framework-agnostic Plugins"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"404\" src=\"./banner.png\" alt=\"vite + wasm pic\"/\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e\n  \n🦀 Vite plugin for rust [wasm-pack](https://github.com/rustwasm/wasm-pack), it's simple.\n  \n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e\n  \n[![npm](https://img.shields.io/npm/v/vite-plugin-wasm-pack.svg)](https://www.npmjs.com/package/vite-plugin-wasm-pack)\n[![npm](https://img.shields.io/npm/dt/vite-plugin-wasm-pack)](https://www.npmjs.com/package/vite-plugin-wasm-pack)\n[![npm](https://img.shields.io/github/license/nshen/vite-plugin-wasm-pack)](https://www.npmjs.com/package/vite-plugin-wasm-pack)\n  \n\u003c/h4\u003e\n\n## Quick start\n\nMake sure [wasm-pack](https://github.com/rustwasm/wasm-pack) installed correctly.\n\nClone this repo or download the [zip file](https://github.com/nshen/vite-plugin-wasm-pack/archive/refs/heads/main.zip), extract the example folder.\n\n```\nexample\n  |\n  |-- my-crate       # rust project folder, there is a Cargo.toml in it\n  |-- src            # front end source code\n  |   |-- index.ts   # entry point\n  |-- index.html     # html entry\n  |-- vite.config.ts # vite config file\n  |__ package.json   # npm config file\n```\n\nInstall npm develop dependencies, **in example folder** run:\n\n```bash\nyarn install\n# or\n# npm install\n```\n\nAfter that you can build `rust project` to `WebAassembly` by using `wasm-pack`.\n\n```bash\nwasm-pack build ./my-crate --target web\n```\n\nNow the `my-crate` module is ready, start vite dev server.\n\n```bash\nyarn dev\nor\n#npm run dev\n```\n\nDone, if below is showing.\n\n```bash\n  vite v2.6.5 dev server running at:\n\n  \u003e Local: http://localhost:3000/\n\n  ready in 169ms.\n```\n\n---\n\n## Install manually\n\n```bash\nyarn add vite vite-plugin-wasm-pack -D\n# or\n# npm i vite vite-plugin-wasm-pack vite -D\n```\n\n## Usage\n\nAdd this plugin to `vite.config.ts`\n\n```js\nimport { defineConfig } from 'vite';\nimport wasmPack from 'vite-plugin-wasm-pack';\n\nexport default defineConfig({\n  // pass your local crate path to the plugin\n  plugins: [wasmPack('./my-crate')]\n});\n```\n\nAdd script to `package.json`\n\n```json\n\"scripts\": {\n  \"dev\": \"vite\",\n  \"build\": \"vite build\"\n}\n```\n\n⚠ **Don't forget to build your [wasm-pack](https://github.com/rustwasm/wasm-pack) crate first!**\n\n```bash\nwasm-pack build ./my-crate --target web\n```\n\nTips: you can add a `wasm` script to `package.json` like this:\n\n```json\n\"scripts\": {\n    \"wasm\": \"wasm-pack build ./my-crate --target web\",\n    \"dev\": \"yarn wasm \u0026\u0026 vite\",\n    \"build\": \"vite build\"\n}\n```\n\nThen, run:\n\n```bash\nyarn dev\n```\n\nThis will start dev server, and install `my-crate` that you built earlier.\n\n## Use wasm-pack package installed via npm\n\nIf you want use a package from npm that built with wasm-pack, like this one [test-npm-crate](https://www.npmjs.com/package/test-npm-crate)\n\nyou have to pass the package name to the second param of our plugin.\n\n`wasmPack(['./my-local-crate'],['test-npm-crate'])`\n\nfull example is in [./npm-crate-example](./npm-crate-example) folder.\n\nnotice, we only support package build with `--target web` for now , if a package you use is built without `--target web`, you should rebuild it. \n\nlike this example  [[Photon-vite]](http://github.nshen.net/photon-vite/) [[source]](https://github.com/nshen/photon-vite)\n\n## Cache Problem\n\nI'm not sure if anybody have met the problem that after modified your package, your package don't update.\n\nThat's becasue vite pre bundling your package, you can follow [vite guide](\nhttps://vitejs.dev/guide/dep-pre-bundling.html) to solve the problem.\n\nIf you met the problem , or any problems. feel free to [create an issue](https://github.com/nshen/vite-plugin-wasm-pack/issues), let me see if I can do something to help you, thanks.\n\n## Examples\n\n- Quick starter is in [./example](./example) folder.\n- Game of life [[demo]](http://github.nshen.net/vite-wasm-game-of-life/dist/) [[source]](https://github.com/nshen/vite-wasm-game-of-life)\n- Photon-vite [[demo]](http://github.nshen.net/photon-vite/) [[source]](https://github.com/nshen/photon-vite)\n\n\n## License\n\nMIT, see [the license file](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnshen%2Fvite-plugin-wasm-pack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnshen%2Fvite-plugin-wasm-pack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnshen%2Fvite-plugin-wasm-pack/lists"}