Back to Tsx

CommonJS output

notes/oxc-transform/commonjs-output.md

4.23.91.3 KB
Original Source

CommonJS output

The NAPI transform exposes source language/module classification but no output-module option (public options); NAPI conversion leaves the internal module option at its default Preserve value (conversion, default). sourceType: "commonjs" changes parser rules, not ESM-to-CJS output (source classification).

The TypeScript module pass lowers only import = require() and export =; it notes that general CommonJS insertion belongs to a future plugin (implementation). Ordinary ESM imports, exports, re-exports, live bindings, and top-level await remain ESM syntax; CommonJS source classification can diagnose top-level await but does not lower it.