All Projects → mxseev → Rust Loader

mxseev / Rust Loader

Licence: mit
Webpack loader for Rust files. DEPRECATED, use WasmPack instead

Programming Languages

javascript
184084 projects - #8 most used programming language
rust
11053 projects

Projects that are alternatives of or similar to Rust Loader

Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (+1676.47%)
Mutual labels:  webpack, wasm
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
Rust Wasm Blob
Softbody physics in Rust with WASM
Stars: ✭ 18 (-47.06%)
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
Luna
Manage npm dependencies through a modern UI.
Stars: ✭ 948 (+2688.24%)
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
Robinhood React
Robinhood trading with ReactJS
Stars: ✭ 31 (-8.82%)
Mutual labels:  webpack
Cppwasm Book
📚 WebAssembly friendly programming with C/C++ -- Emscripten practice
Stars: ✭ 956 (+2711.76%)
Mutual labels:  wasm
Rhai
Rhai - An embedded scripting language for Rust.
Stars: ✭ 958 (+2717.65%)
Mutual labels:  wasm
Angular2 Webpack Boilerplate
A boilerplate for Angular 2 and Webpack
Stars: ✭ 30 (-11.76%)
Mutual labels:  webpack
Webpack Optimization
webpack,webpack2 优化之路,(已停止更新)
Stars: ✭ 32 (-5.88%)
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 via file-loader
  • Hot module replacement

Usage

  1. Prepare system
    1. Install nightly Rust: rustup update nightly
    2. Install rustc wasm target: rustup target add wasm32-unknown-unknown --toolchain nightly
    3. Install wasm-gc: cargo install --git https://github.com/alexcrichton/wasm-gc --force
  2. Configure Webpack
    1. Install rust-loader and file-loader: yarn add rust-loader file-loader --dev
    2. Use it in Webpack config:
    rules: [
      {
        test: /(\.rs$|Cargo.toml)/,
        loader: "rust-loader"
      },
      {
        test: /\.wasm$/,
        loader: "file-loader",
        type: "javascript/auto"
      }
    ]
    
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].