{"library":"rollup-plugin-rust","title":"rollup-plugin-rust","description":"A Rollup plugin that compiles Rust code into WebAssembly modules, enabling seamless interop between Rust and JavaScript projects. Version 1.2.0, currently in active development with no recent updates. Requires Node >= 8.9.0, Rollup >= 0.64.0, and Rust nightly with wasm32-unknown-unknown target. Supports various export modes (WebAssembly.Instance, WebAssembly.Module, buffer), release/debug builds, and custom include/exclude patterns. Differentiates from other WASM plugins by focusing specifically on Rust compilation via the rustc compiler, offering tight integration with Rollup's build pipeline.","language":"javascript","status":"active","last_verified":"Mon Apr 27","install":{"commands":["npm install rollup-plugin-rust"],"cli":null},"imports":["import rust from 'rollup-plugin-rust'","import rust from 'rollup-plugin-rust'; rust({ release: false })","import type { RustOptions } from 'rollup-plugin-rust'","import type { RustPlugin } from 'rollup-plugin-rust'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// rollup.config.js\nimport rust from 'rollup-plugin-rust';\n\nexport default {\n  input: 'src/main.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm'\n  },\n  plugins: [rust({ release: true })]\n};\n\n// lib.rs\n// #[no_mangle]\n// pub fn add(a: i32, b: i32) -> i32 {\n//     a + b\n// }\n\n// src/main.js\nimport wasm from './lib.rs';\n\nexport async function increment(a) {\n  const { instance } = await wasm;\n  return instance.exports.add(1, a);\n}","lang":"javascript","description":"Shows a minimal Rollup configuration using the plugin to compile Rust to WASM, and how to import and use the WASM module in JavaScript.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}