Registry / devops / rollup-plugin-zigar

rollup-plugin-zigar

JSON →
library0.15.2jsnpmunverified

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-zigar
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-ZIGA
R
rollup-plugin-zigar
devopsjavascriptv0.15.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import zigar from 'rollup-plugin-zigar'
✗ const zigar = require('rollup-plugin-zigar')
ESM-only; CJS require will fail.
zigar
✓ import { zigar } from 'rollup-plugin-zigar'
✗ import { zigarPlugin } from 'rollup-plugin-zigar'
Named export is exactly 'zigar', not 'zigarPlugin'.

Shows how to integrate the Zigar plugin into a Rollup config to transpile Zig imports (e.g., from .zig files) into JavaScript modules.

// rollup.config.js import zigar from 'rollup-plugin-zigar'; export default { input: 'src/main.js', output: { dir: 'dist', format: 'esm', }, plugins: [ zigar({ // optional: specify Zig compiler path // zigPath: '/usr/local/bin/zig', }), ], };
Debug
Known issues
breakingZigar v0.15 changed the plugin API: options object is no longer optional; zigar() now requires a config argument.
fix
Pass an empty object explicitly: zigar({}).
affects: >=0.15.0
breakingNode.js <14 are unsupported in v0.14+. ESM-only distribution removed CJS support.
fix
Upgrade to Node.js 14+ and use ESM imports (i.e., package.json type: module or .mjs extension).
affects: >=0.14.0
deprecatedSupport for Rollup <3 is deprecated; future versions will require Rollup 3+.
fix
Update Rollup to 3.x or later.
affects: >=0.13.0
gotchaPlugin only works with .zig files that export a main function. Exported functions must be public and have compatible signatures for WASM.
fix
Ensure your Zig source exports a pub fn main() or pub fn exportedFunction() callable from JS.
affects: *
Errors
Common errors & fixes
Error: Could not resolve './foo.zig' from 'src/bar.js'
Rollup cannot handle .zig files without the plugin or the plugin is not configured.
fix
Ensure the zigar plugin is included in the plugins array of your Rollup config.
TypeError: zigar is not a function
Default import fails if package is not resolved correctly, possibly due to missing ESM support.
fix
Check that your project uses ESM (type: module in package.json) and Node.js >=14.
Upgrade
Version history
0.15.2latest on npm
Audit
Dependencies
rolluprequiredPeer dependency: requires Rollup >=2.0 for plugin interface
@rollup/pluginutilsoptionalUsed for file filtering and ID resolution
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-zigar — npm install rollup-plugin-zigar · libregistry