rust-wasmpack-loader v3.0.2
Rust Wasm-pack Loader
Native wasm Webpack loader for .rs
(Rust) resources
Works with webpack
^5.0.0
Works fine with
web
andnode
(node-async
) targets
Dynamically finds the Cargo.toml
file for building the wasm source.
Provides the ability to use both wasm_bindgen
and regular functions.
Allows you to use the standard import of a .rs
file in a .js
or .ts
file without any headache
Installation
Install rust-wasmpack-loader
with npm
npm i rust-wasmpack-loader
Or install into Dev dependencies
npm i --save-dev rust-wasmpack-loader
Usage
Add .rs rule to webpack config
// webpack.config.js
module.exports = {
// ...
module: {
// ...
rules: [
// ...
{
test: /\.rs$/,
exclude: /node_modules/,
use: [
{
loader: "rust-wasmpack-loader",
},
],
},
]
}
}
Also, create Cargo.toml
file (in root or in folder, where you want to create .rs
file)
# Cargo.toml
[package]
name = "wasm-fibonacci-test"
version = "0.1.0"
authors = ["Yehor Brodskiy"]
[lib]
crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2.73"
Options
parameter | type | default | description |
---|---|---|---|
web | object | options, which used for web target | |
node | object | options, which used for node target | |
web.asyncLoading | boolean | false | enables load .wasm file asynchronously, instead of bundling in .js file |
web.wasmPathModifier | array<string> | ["/"] | rewrite wasm requestPath, if wrong publicPath used |
web.publicPath | boolean | true | use webpack PublicPath |
node.bundle | boolean | false | Bundle .wasm file in .js file (additional .wasm file will not create) |
logLevel | string | info | Log Level (verbose , info , warn , error , quiet ) |
Examples
Check the example folder for a better understanding of how the loader works
Contributing
Contributions are always welcome!
See CONTRIBUTING.md for ways to get started.
Acknowledgements
License
3 months ago
5 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago