feat(napi/parser, napi/transform): accept sourceType: "commonjs"#18197
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
3b38774 to
ef08b7c
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends support for the commonjs source type to NAPI packages (oxc-parser and oxc-transform), building on the parser support added in #18089. The change allows users to explicitly specify sourceType: 'commonjs' when parsing or transforming code.
Changes:
- Updated TypeScript type definitions across parser, transform, and oxlint packages to include
'commonjs'as a validsourceTypeoption - Added implementation support in the shared
get_source_typefunction to handle the'commonjs'case - Added comprehensive test coverage for the new
commonjssource type in the parser package
Reviewed changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
napi/transform/src/transformer.rs |
Updated TypeScript type annotation to include 'commonjs' option |
napi/transform/index.d.ts |
Updated TypeScript interface to include 'commonjs' in sourceType union |
napi/parser/test/parse.test.ts |
Added comprehensive tests for sourceType: 'commonjs' across all language types |
napi/parser/src/types.rs |
Updated TypeScript type annotation to include 'commonjs' option |
napi/parser/src-js/index.d.ts |
Updated TypeScript interface to include 'commonjs' in sourceType union |
crates/oxc_napi/src/lib.rs |
Added commonjs case handling in get_source_type function and minor documentation improvement |
apps/oxlint/src/js_plugins/parse.rs |
Updated TypeScript type annotation to include 'commonjs' option |
apps/oxlint/src-js/bindings.d.ts |
Updated TypeScript interface to include 'commonjs' in sourceType union |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4d0e4d0 to
ff4edd2
Compare
ef08b7c to
80fc51f
Compare
80fc51f to
9a5146e
Compare
Merge activity
|
9a5146e to
6e8fa80
Compare

#18089 added support in parser for
commonjssource type.Extend this support to the NAPI packages - accept
sourceType: 'commonjs'in options foroxc-parserandoxc-transform.