-
-
Notifications
You must be signed in to change notification settings - Fork 46
feat!: migrate to oxc-parser and oxc-walker
#527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughReplaces acorn and estree-walker with oxc-parser, oxc-walker, and updates oxc-transform; updates imports and parsing/walking calls in bundle-utils files and test utils, adapts AST extraction and walker callback signatures; public APIs unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller as generate()/validateSyntax
participant Parser as oxc-parser.parseSync
participant Walker as oxc-walker.walk
participant Generator as code generation logic
Note over Caller,Parser `#DDDDFF`: New parse flow
Caller->>Parser: parse source (lang:'js', sourceType:'module')
Parser-->>Caller: { program: ast }
Caller->>Walker: walk(ast, { enter, leave })
Walker-->>Generator: invoke enter/leave for nodes (node, parent)
Generator-->>Caller: produced output / validation result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
oxc-parser and oxc-walker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/bundle-utils/src/js.ts (2)
189-197: Remove outdated comment about estree-walker.Lines 191-195 contain an outdated comment referencing
[email protected]and dual packages. Since the codebase now usesoxc-walker, this comment is misleading and should be removed.walk(node, { - /** - * NOTE: - * force cast to Node of `[email protected]`, - * because `[email protected]` is not dual packages, - * so it's support only esm only ... - */ // @ts-ignore enter(node, parent) {
155-180: Fix property access to usespan.startandspan.endon oxc-parser nodes.Lines 165 and 170 incorrectly access
node.startandnode.end. oxc-parser nodes expose these via thespanproperty: usenode.span.startandnode.span.endinstead.
- Line 165: Change
node.start, node.end→node.span.start, node.span.end- Line 170: Change
node.start, node.end→node.span.start, node.span.endThe
@ts-expect-errorsuppressions are masking real type errors. After fixing the property access, remove the suppressions to ensure proper type safety.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
packages/bundle-utils/test/generator/__snapshots__/js.test.ts.snapis excluded by!**/*.snappnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (4)
packages/bundle-utils/package.json(1 hunks)packages/bundle-utils/src/js.ts(4 hunks)packages/bundle-utils/src/ts.ts(1 hunks)packages/bundle-utils/test/utils.ts(2 hunks)
🔇 Additional comments (7)
packages/bundle-utils/src/ts.ts (1)
7-7: LGTM! Type import correctly migrated to oxc-parser.The Node type import change aligns with the broader migration strategy and maintains the existing function signature.
packages/bundle-utils/src/js.ts (3)
7-8: LGTM! Parser and walker imports correctly migrated.The imports from
oxc-parserandoxc-walkerreplace the previousacornandestree-walkerdependencies as intended.
54-57: Parsing API correctly adapted to oxc-parser.The
parseSynccall and destructuring of{ program: ast }correctly reflects the oxc-parser API. The optionssourceType: 'module'andlang: 'js'are appropriate.
197-214: Parent parameter usage is correct.The
parentparameter from oxc-walker is properly handled with optional chaining (parent?.type), which correctly accounts for the root node where parent isnullorundefined.packages/bundle-utils/test/utils.ts (3)
2-2: LGTM! Test utility correctly migrated to oxc-parser.The import change aligns with the overall migration strategy.
17-19: Syntax validation correctly adapted to oxc-parser API.The
parseSyncusage with appropriate parameters correctly validates JavaScript syntax.
22-22: Nice catch on the typo fix!Correcting "invalid sytanx" to "invalid syntax" improves the error message quality.
commit: |
kazupon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mini-ghost
Thank you for your contribution and welcome!
This is great PR!
LGTM!
Description
This PR migrates JavaScript/TypeScript parsing from
acornandestree-walkerto the OXC toolchainThis is a follow-up to #525, completing the migration to a unified OXC toolchain for all JS/TS parsing and transformation, with expected performance improvements.
Linked Issues
N/A
Additional context
I'm not sure if CJS support is still needed (based on the original comments). If there are any concerns, please feel free to close this. Thank you!
Summary by CodeRabbit
Chores
Bug Fixes