mxseev / Rust Loader
Licence: mit
Webpack loader for Rust files. DEPRECATED, use WasmPack instead
Stars: ✭ 34
Programming Languages
javascript
184084 projects - #8 most used programming language
rust
11053 projects
Projects that are alternatives of or similar to Rust Loader
Carton
📦 Watcher, bundler, and test runner for your SwiftWasm apps
Stars: ✭ 171 (+402.94%)
Mutual labels: webpack, wasm
Modern Wasm Starter
🛸 Run C++ code on web and create blazingly fast websites! A starter template to easily create WebAssembly packages using type-safe C++ bindings with automatic TypeScript declarations.
Stars: ✭ 140 (+311.76%)
Mutual labels: webpack, wasm
Preact Boilerplate
🎸 Ready-to-rock Preact starter project, powered by Webpack.
Stars: ✭ 959 (+2720.59%)
Mutual labels: webpack
Jekyll Boilerplate
Helpful files to get started working on a new Jekyll website
Stars: ✭ 30 (-11.76%)
Mutual labels: webpack
Event Hooks Webpack Plugin
Event hooks plugin for webpack
Stars: ✭ 30 (-11.76%)
Mutual labels: webpack
React Webpack Lazy Loading
A sample of lazy loading using React and Webpack
Stars: ✭ 33 (-2.94%)
Mutual labels: webpack
Pyramidvue
Pyramid Web Framework (Python) implemented with Vuejs (JavaScript) & Webpack (HMR): starter template
Stars: ✭ 32 (-5.88%)
Mutual labels: webpack
Cppwasm Book
📚 WebAssembly friendly programming with C/C++ -- Emscripten practice
Stars: ✭ 956 (+2711.76%)
Mutual labels: wasm
Angular2 Webpack Boilerplate
A boilerplate for Angular 2 and Webpack
Stars: ✭ 30 (-11.76%)
Mutual labels: webpack
Wasm Check
TypeScript / JavaScript library for detect WebAssembly features in node.js & browser
Stars: ✭ 30 (-11.76%)
Mutual labels: wasm
Vue Auth Boilerplate
🔑 Vue.js scalable boilerplate with user authentication.
Stars: ✭ 31 (-8.82%)
Mutual labels: webpack
Minimal Vue Worker
A minimal example of a Web Worker in VueJS (Vue CLI 3)
Stars: ✭ 32 (-5.88%)
Mutual labels: webpack
Wasmsign
A tool to add and verify digital signatures to/from WASM binaries
Stars: ✭ 31 (-8.82%)
Mutual labels: wasm
Procedural Ar
Using simplex noise to procedurally generate a map in Spark AR
Stars: ✭ 31 (-8.82%)
Mutual labels: webpack
The project is in low maintance now
Use WasmPack instead
Webpack Rust loader
Webpack loader for Rust
Example
add.rs
#[no_mangle]
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
huge_crate/Cargo.toml
[lib]
crate-type = ["cdylib"] # important
huge_crate/src/lib.rs
fn its_magic_number(x: i32) -> bool {
x == 42
}
#[no_mangle]
pub fn plus_one(x: i32) -> i32 {
if its_magic_number(x) { 420 } else { x + 1 }
}
main.js
import add from "./add.rs"
import hugeCrate from "./huge_crate/Cargo.toml"
(async () => {
const add = await add.then(buf => WebAssembly.instantiate(buf))
const hugeCrate = await hugeCrate.then(buf => WebAssembly.instantiate(buf))
console.log(add.instance.exports.add(1, 2)) // 3
console.log(hugeCrate.instance.exports.plus_one(6)) // 7
console.log(hugeCrate.instance.exports.plus_one(42)) // 420
})()
Features
- Dont injects WASM to JS bundle, dynamic http fetching
.wasm
files viafile-loader
- Hot module replacement
Usage
- Prepare system
- Install nightly Rust:
rustup update nightly
- Install rustc wasm target:
rustup target add wasm32-unknown-unknown --toolchain nightly
- Install wasm-gc:
cargo install --git https://github.com/alexcrichton/wasm-gc --force
- Install nightly Rust:
- Configure Webpack
- Install
rust-loader
andfile-loader
:yarn add rust-loader file-loader --dev
- Use it in Webpack config:
rules: [ { test: /(\.rs$|Cargo.toml)/, loader: "rust-loader" }, { test: /\.wasm$/, loader: "file-loader", type: "javascript/auto" } ]
- Install
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].