__zigar.connect(obj) - chung-leong/zigar GitHub Wiki

Use a different console object to display output to stdout and stderr. Only its log method will get called, always with a single string as argument.

const std = @import("std");

pub fn hello() void {
    std.debug.print("hello\n", .{});
}
import { __zigar, hello } from './special-exports-example-1.zig';
const { connect } = __zigar;

connect({
    log(s) {
        console.log(`Zig output: "${s}"`);
    }
});
hello();

Special exports: __zigar