{"id":13827637,"url":"https://github.com/ianjsikes/rust-wasm-loader","last_synced_at":"2025-07-09T04:33:04.869Z","repository":{"id":65373247,"uuid":"94850015","full_name":"ianjsikes/rust-wasm-loader","owner":"ianjsikes","description":"Webpack loader for Rust","archived":false,"fork":true,"pushed_at":"2019-06-20T02:41:59.000Z","size":84,"stargazers_count":82,"open_issues_count":2,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-10T10:42:53.871Z","etag":null,"topics":["javascript","rust","wasm","webassembly","webpack"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/rust-wasm-loader","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mrdziuban/rust-emscripten-loader","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ianjsikes.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}},"created_at":"2017-06-20T04:33:24.000Z","updated_at":"2023-06-07T01:54:26.000Z","dependencies_parsed_at":"2023-01-20T02:18:31.197Z","dependency_job_id":null,"html_url":"https://github.com/ianjsikes/rust-wasm-loader","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianjsikes%2Frust-wasm-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianjsikes%2Frust-wasm-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianjsikes%2Frust-wasm-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianjsikes%2Frust-wasm-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ianjsikes","download_url":"https://codeload.github.com/ianjsikes/rust-wasm-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225486378,"owners_count":17481885,"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":["javascript","rust","wasm","webassembly","webpack"],"created_at":"2024-08-04T09:02:04.025Z","updated_at":"2024-11-20T07:30:52.182Z","avatar_url":"https://github.com/ianjsikes.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Rust WebAssembly loader\n\n[![npm](https://img.shields.io/npm/v/rust-wasm-loader.svg)](https://www.npmjs.com/package/rust-wasm-loader)\n\n## Usage\n\nThis is a simple Webpack loader that shells out to cargo to build a Rust project targeting WebAssembly. See [this post](https://www.hellorust.com/setup/wasm-target/) for\nmore details on using Rust to target the web.\n\nTo use it, first install the package:\n\n```bash\n$ npm install rust-wasm-loader\n```\n\nConfigure the loader in your Webpack config:\n\n```js\nmodule.exports = {\n  // ...\n  module: {\n    rules: [\n      {\n        test: /\\.rs$/,\n        use: {\n          loader: 'rust-wasm-loader',\n          options: {\n            // Path to your 'build' or 'dist' directory relative to project root\n            path: 'build/',\n          }\n        }\n      },\n      // ...\n    ]\n  }\n}\n```\n\nNote: if you are using `file-loader`, make sure to add `.wasm` to the test field, otherwise the module will not be copied! (e.g. `test: /\\.(wasm|jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i,`).\n\nMake sure you have the `cargo`, `rustc`, and (optionally) `emsdk` binaries somewhere in your `PATH`.  `stdweb` and other Rust libraries require a nightly build, which can be installed from https://rustup.rs/ .\n\nRequire and initialize the wasm module:\n\n```js\nconst wasm = require('./lib.rs')\nwasm.then(module =\u003e {\n  // Use your module here\n  console.log(module.doub(21))\n})\n```\n\nor with async/await:\n\n```js\nasync function loadwasm() {\n  const lib = await require('./lib.rs');\n  // Use your module here\n  console.log(lib.doub(21));\n}\nloadwasm();\n```\n\n### Configuration\n\nThe following options can be added to the Webpack loader query:\n\n| Name | Description | Required | Default |\n| ---- | ----------- | -------- | ------- |\n| `release` | Whether or not to pass the `--release` flag to cargo | false | false |\n| `path` | Path to your webpack output folder relative to project root | true | '' |\n| `target` | Allows one to specify `wasm32-unknown-emscripten` as build target | false | 'wasm32-unknown-unknown' |\n\n### Example\n\nCheck out the [example](example) directory for a simple Hello World example.\n\nThis project is based off of [rust-emscripten-loader](https://github.com/mrdziuban/rust-emscripten-loader)\nby [mrdziuban](https://github.com/mrdziuban).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianjsikes%2Frust-wasm-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fianjsikes%2Frust-wasm-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianjsikes%2Frust-wasm-loader/lists"}