โ† Back
unjs

unjs/oxbox

๐Ÿ‚ Tiny, portable JS library for parsing and transforming JS/TS/JSX, powered by oxc

View on GitHub โ†—https://oxbox.unjs.io โ†—
Stars
41
Forks
0
Watchers
41
Open issues
2
Contributors
2
Language
TypeScript
License
Other
Default branch
main
Created Sep 28, 2026Updated Sep 29, 2026

Star growth

Todayโ€”
This weekโ€”
This monthโ€”

Star history will appear here once this repo has been tracked for a couple of days.

README

oxbox ๐Ÿ‚

A tiny, portable JS library for parsing and transforming JS/TS/JSX, powered by oxc.

  • โšก Optimized wasm build in a single JS chunk, zero dependencies
  • ๐Ÿชž Same API as oxc-parser + oxc-transform
  • ๐Ÿค Works in browsers and Node.js
  • ๐Ÿ’พ Fits on a floppy disk

๐Ÿ‘‰ Try it in the online playground.

Usage

import { parseSync, transformSync } from "oxbox";

const { code } = transformSync("input.ts", "const a: number = 1");
const { program } = parseSync("input.ts", "const a: number = 1");

All oxc-parser and oxc-transform exports are available (parse, parseSync, transform, transformSync, isolatedDeclaration, moduleRunnerTransform, ...), so oxbox can be used as a drop-in replacement.

The wasm is decoded, decompressed and instantiated lazily on first call. Use await init() to warm it up ahead of time (required before calling sync APIs in browsers).

Async APIs run on a prewarmed worker pool when SharedArrayBuffer is available (in browsers, the page must be cross-origin isolated); otherwise oxbox runs single-threaded and async APIs run on the calling thread.

How it works

The official oxc packages ship the parser and transformer as separate binaries, and since the transformer includes its own parser, much of it is duplicated. They also pull in dozens of platform bindings and a JS runtime (emnapi + napi-rs).

oxbox instead:

  • ๐Ÿ”— Links parser and transformer into one wasm binary, optimized together (LTO)
  • โšก Enables SIMD (simd128) across the whole build, not just in a few hand-written spots
  • ๐Ÿ—œ๏ธ Embeds the wasm in the JS bundle, compressed with zopfli (deflate-raw) and base93-encoded
  • ๐Ÿชถ Replaces platform bindings and the emnapi / napi-rs runtime with its own tiny N-API + WASI host that runs in Node.js and browsers
  • ๐Ÿงต Runs async APIs on a multithreaded, prewarmed worker pool

Benchmarks

Compared with the official oxc-transform / oxc-parser wasm and native (napi) bindings.

Install size

Install size: oxbox vs oxc (wasm) vs oxc (napi)

oxbox ships transform and parser as a single wasm; oxc ships them as two packages (and the wasm bindings share the emnapi / napi-rs runtime).

Performance

Benchmarks: oxbox vs oxc (wasm) vs oxc (napi)

Development

local development
  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run the browser playground using pnpm dev
  • Run tests using pnpm vitest
  • Run benchmarks against oxc-transform / oxc-parser (napi and wasm) using pnpm bench [filter] (unfiltered runs save bench/results.json; pnpm bench:report re-renders bench/results.svg from it) and install sizes using pnpm bench:size (renders bench/size.svg)
  • Rebuild the wasm from oxc sources (committed as src/_vendor/wasm.ts) using pnpm vendor (requires Rust and rustup target add wasm32-wasip1-threads)

License

Published under the MIT license ๐Ÿ’›.

Bundles oxc (MIT, VoidZero Inc. & Contributors). The N-API / WASI host (src/napi.ts) is derived from emnapi (MIT, Toyobayashi) and the napi-rs wasm runtime (MIT, LongYinan). See LICENSE for full license texts.