This document provides guidelines for AI coding agents working in this repository.
This project audits Node.js API compatibility across different runtimes (Node.js, Bun, Deno, Cloudflare Workers/workerd). It generates JSON dumps of runtime APIs and displays compatibility in a React-based report at https://workers-nodejs-compat-matrix.pages.dev
- Node.js v22 (required for generation scripts)
- fnm (for Node version management) - set
FNM_DIRenv var to fnm binary location - Deno and Bun installed
- pnpm 10.0.0
# Install dependencies
pnpm install
# Generate full compatibility report (requires Node 18, 20, 22 via fnm)
pnpm run generate
# Scan APIs for specific runtimes only
node ./scan-apis.mjs --only workerd
node ./scan-apis.mjs --only bun,deno
# Generate table data for UI (after scanning)
pnpm run generate:table
# Generate historical trend data (scans multiple workerd versions)
pnpm run generate:historical
# Serve React report locally
pnpm run report:dev
# Build report for production
pnpm run --filter report build
# Deploy to Cloudflare Pages
pnpm run report:deploy# Workerd (with compatibility date)
node workerd/dump.mjs 2025-01-01
# Bun
bun run bun/dump.js
# Deno
deno run --allow-all deno/dump.js
# Node.js (requires fnm)
fnm exec --using=22 node node/dump.mjs --compare-to-baseline/data/- Generated JSON dumps (baseline.json, workerd.json, bun.json, deno.json, node-*.json)/node/,/bun/,/deno/,/workerd/- Runtime-specific dump scripts/report/- React app for visualizing compatibility/report/src/data/- Data files consumed by React app (table-data.json, historical-support.json)dump-utils.mjs- Shared utilities for traversing and comparing APIsgenerate-*.mjs- Scripts for generating various data filesscan-apis.mjs- Orchestrates scanning across all runtimes
- Use Prettier with project config (
.prettierrc) - Semicolons: required
- Quotes: double quotes
- Print width: 80
- Trailing commas: ES5 style
Node built-ins first (with node: protocol), then third-party, then local:
import fs from "node:fs/promises";
import path from "node:path";
import shell from "shelljs";
import { visit } from "../dump-utils.mjs";- Strict mode enabled
- Use
typefor simple types, interfaces for React props - Use Zod for runtime validation
- JSON imports:
import data from "./file.json" with { type: "json" };
- Variables/functions: camelCase
- Constants: SCREAMING_SNAKE_CASE
- React components: PascalCase
- Files: kebab-case for scripts, PascalCase for React components
- Use
try/catchfor expected errors - Use
shell.set("-e")in shell scripts for fail-fast - Check for required tools at script start
- Baseline generation: Merges Node 18/20/22 APIs into
baseline.json - API scanning: Dumps APIs from each runtime, comparing to baseline
- Table generation: Creates
table-data.jsonfrom JSON dumps - Historical tracking:
generate-historical-data.mjstracks workerd support over time - React app: Renders interactive table and trend chart
- Support states:
supported,unsupported,mismatch(no stubs counted) - Display icons: ✅ (matching), ❌ (missing), 🩹 (mismatch)
- Target runtimes: Order in
generate-table-data.mjsMUST matchApp.tsx
- No unenv/stubs: Stubs are treated as missing/unsupported, not counted toward support
- Workerd data only: The Cloudflare Workers column uses raw workerd data
- Historical data: Uses workerd directly with different compatibility dates
- API dumps are committed to git (not gitignored)
- Node v22 features required for generation scripts
pnpm run generatenode ./scan-apis.mjs --only workerd
pnpm run generate:tablepnpm run generate:historicalEdit report/src/ignored-modules.js, then:
pnpm run generate:baseline && pnpm run generate:tableGitHub Actions (.github/workflows/deploy-report.yml):
- Triggers: push to main, daily at 1:15am, manual dispatch
- Builds and deploys report to Cloudflare Pages
- Does NOT regenerate API dumps (uses committed data)