A Rollup plugin (v0.15.2) that transpiles Zig source code into JavaScript/WASM, enabling Zig to be used as a dependency in web bundles. Released as part of the Zigar toolchain, it compiles Zig to WebAssembly and generates JS wrappers for seamless import in Rollup-based projects. Rapidly evolving (pre-1.0). Differentiates from Emscripten by targeting direct Zig compilation for bundlers.
npm install rollup-plugin-zigarVerified import paths — ran on the pinned version, not inferred.
Shows how to integrate the Zigar plugin into a Rollup config to transpile Zig imports (e.g., from .zig files) into JavaScript modules.
Pass an empty object explicitly: zigar({}).Upgrade to Node.js 14+ and use ESM imports (i.e., package.json type: module or .mjs extension).
Update Rollup to 3.x or later.
Ensure your Zig source exports a pub fn main() or pub fn exportedFunction() callable from JS.
Ensure the zigar plugin is included in the plugins array of your Rollup config.
Check that your project uses ESM (type: module in package.json) and Node.js >=14.