Skip to content

Conversation

@Mini-ghost
Copy link
Contributor

@Mini-ghost Mini-ghost commented Nov 5, 2025

Description

This PR migrates JavaScript/TypeScript parsing from acorn and estree-walker to the OXC toolchain

This 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

    • Updated core parsing and AST-walking implementation to improve compatibility and reliability; no changes to public behavior or user-facing output.
  • Bug Fixes

    • Corrected a typo in a syntax error message so errors are clearer.

@coderabbitai
Copy link

coderabbitai bot commented Nov 5, 2025

Walkthrough

Replaces 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

Cohort / File(s) Summary
Dependencies
packages/bundle-utils/package.json
Removed acorn and estree-walker; added oxc-parser (^0.96.0) and oxc-walker (^0.5.2); bumped oxc-transform to ^0.96.0; removed @types/estree devDependency.
JS parser & walker
packages/bundle-utils/src/js.ts
Replaced acorn + estree-walker usage with oxc-parser.parseSync and oxc-walker; changed Node import source; adapted AST extraction ({ program: ast }) and walker callbacks from (node, _parent) to (node, parent) and parent?.type checks.
TS Node type import
packages/bundle-utils/src/ts.ts
Updated Node import from estree to oxc-parser (no functional changes otherwise).
Test utils parsing
packages/bundle-utils/test/utils.ts
Switched syntax validation to parseSync('test.js', code, { sourceType: 'module' }) and fixed error message typo ("invalid sytanx" → "invalid syntax").

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention areas:
    • Verify AST shape mapping from oxc-parser ({ program: ast }) versus previous acorn AST expectations.
    • Confirm walker enter/leave semantics and skip logic with the new (node, parent) signature.
    • Check places relying on estree-specific types or node fields for compatibility.

Suggested reviewers

  • kazupon

Poem

🐰 I parse the fields where old acorns stood,
New walkers hop where branches once would,
Program becomes ast, parents now show,
Tiny hops make the bundle grow,
A nimble rabbit says: "Ready? Go!" 🥕

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: migrating from acorn/estree-walker to oxc-parser/oxc-walker. This matches the primary objective and all file-level changes.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20cb21b and bf93818.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • packages/bundle-utils/package.json (1 hunks)
🔇 Additional comments (1)
packages/bundle-utils/package.json (1)

25-27: OXC package versions are correctly aligned.

oxc-walker 0.5.2 is intended to work with current oxc-parser releases including 0.96.0, as oxc-walker is built on top of oxc-parser. The version difference between oxc-walker (0.5.x) and oxc-parser/oxc-transform (0.96.x) reflects intentional separate versioning within the OXC ecosystem. The critical version mismatch from the prior review (oxc-parser 0.96.0 with oxc-transform 0.95.0) has been resolved.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mini-ghost Mini-ghost changed the title feat!: migrate to oxc-parser and oxc-walker feat!: migrate to oxc-parser and oxc-walker Nov 5, 2025
@Mini-ghost Mini-ghost marked this pull request as ready for review November 5, 2025 13:29
Copy link

@coderabbitai coderabbitai bot left a 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 uses oxc-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 use span.start and span.end on oxc-parser nodes.

Lines 165 and 170 incorrectly access node.start and node.end. oxc-parser nodes expose these via the span property: use node.span.start and node.span.end instead.

  • Line 165: Change node.start, node.endnode.span.start, node.span.end
  • Line 170: Change node.start, node.endnode.span.start, node.span.end

The @ts-expect-error suppressions 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7c7821c and 5aa59df.

⛔ Files ignored due to path filters (2)
  • packages/bundle-utils/test/generator/__snapshots__/js.test.ts.snap is excluded by !**/*.snap
  • pnpm-lock.yaml is 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-parser and oxc-walker replace the previous acorn and estree-walker dependencies as intended.


54-57: Parsing API correctly adapted to oxc-parser.

The parseSync call and destructuring of { program: ast } correctly reflects the oxc-parser API. The options sourceType: 'module' and lang: 'js' are appropriate.


197-214: Parent parameter usage is correct.

The parent parameter from oxc-walker is properly handled with optional chaining (parent?.type), which correctly accounts for the root node where parent is null or undefined.

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 parseSync usage 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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 5, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@intlify/bundle-utils@527
npm i https://pkg.pr.new/@intlify/unplugin-vue-i18n@527

commit: bf93818

@kazupon kazupon added the feature Includes new features label Nov 5, 2025
Copy link
Member

@kazupon kazupon left a 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!

@kazupon kazupon merged commit 4bbe85c into intlify:main Nov 5, 2025
11 checks passed
@Mini-ghost Mini-ghost deleted the feat/use-oxc branch November 6, 2025 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Includes new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants