ReviewOS

stacks/bun-plugin-dtsx

Switch dts emit to zig-dtsx (via pantry)

#4105
Closed glennmichael123 opened this 8 days ago ·
8 days ago

Goal

Swap bun-plugin-dtsx's dts emit pipeline from the TypeScript @stacksjs/dtsx to the Zig-native @stacksjs/zig-dtsx. Same output, significantly faster.

Background

The Zig implementation has been extracted into a standalone repo at zig-utils/zig-dtsx so it can be released and consumed independently:

  • CLI — distributable via pantry (pantry add zig-dtsx)
  • TS FFI bridge — Bun FFI wrapper published as @stacksjs/zig-dtsx on npm, exposes processSource() / processBatch()
  • Parity — vendored fixture suite (199 tests) validates byte-identical output against the reference TS implementation

Acceptance

  • Add @stacksjs/zig-dtsx as a peer/dev dep (or pantry dep for CLI use)
  • Detect whether the Zig shared library is available (ZIG_AVAILABLE from @stacksjs/zig-dtsx)
  • When available: route per-file dts emit through processSource() / processBatch() instead of the TS path
  • Fall back to the existing @stacksjs/dtsx TS path when Zig isn't available (CI without the binary, unsupported platform, etc.)
  • Benchmark before/after on a representative project (target: at least the speedup numbers documented in zig-dtsx's README)
  • Update README to mention the optional Zig acceleration

Blocked on

  • zig-utils/zig-dtsx 0.1.0 release cut + published binaries (cross-compile matrix already wired in CI)
  • @stacksjs/zig-dtsx npm publish
  • pantry package registration for the CLI

Context

Chris flagged this on 2026-05-13 as a follow-up to the broader own-compiler direction. Pairs with the bundler-mirror task (extract Bun's Zig bundler before the Rust rewrite lands).

Sign in to comment on this issue.