Skip to content

feat: support using rolldown/utils for parsing#537

Merged
antfu merged 2 commits into
mainfrom
feat/rolldown
May 14, 2026
Merged

feat: support using rolldown/utils for parsing#537
antfu merged 2 commits into
mainfrom
feat/rolldown

Conversation

@danielroe

@danielroe danielroe commented May 13, 2026

Copy link
Copy Markdown
Member

sparked by nuxt/nuxt#34983

this allows using parseSync from rolldown/utils (if installed) rather than oxc-parser. the aim is to avoid duplicate installs (rolldown bundles oxc-parser).

Summary by CodeRabbit

  • New Features

    • Added support for rolldown as an alternative parser; the system will detect and prefer rolldown when available and fall back to oxc-parser.
  • Documentation

    • README installation and parser docs updated to show rolldown as the preferred (optional) peer and to clarify the “or” choice for oxc-parser.
  • Chores

    • Package metadata and workspace config updated to mark rolldown as an optional peer and pin its workspace entry.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d81f5045-00b0-4f37-acfe-c67d18eb9af4

📥 Commits

Reviewing files that changed from the base of the PR and between 3e69045 and f62c1ef.

📒 Files selected for processing (3)
  • pnpm-workspace.yaml
  • src/detect-oxc.ts
  • test/detect-estree.test.ts
✅ Files skipped from review due to trivial changes (1)
  • pnpm-workspace.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/detect-estree.test.ts
  • src/detect-oxc.ts

📝 Walkthrough

Walkthrough

Adds rolldown as an optional peer dependency and refactors detectImportsOxc to lazily load parseSync from rolldown or oxc-parser (with caching). Updates package metadata, workspace catalog, tests, and README to reflect dual-parser support.

Changes

Rolldown Parser Integration

Layer / File(s) Summary
Optional peer dependency configuration
pnpm-workspace.yaml, package.json
Added rolldown: ^1.0.0 to workspace catalogs and marked both rolldown and oxc-parser as optional peers in peerDependenciesMeta.
Documentation for dual parser support
README.md
Updated parser docs and install snippet to require either rolldown or oxc-parser (prefer rolldown when both are installed).
Lazy parser loader with fallback selection
src/detect-oxc.ts
Refactored detectImportsOxc from a static detector to an async function that loads parseSync from rolldown/utils or oxc-parser at runtime, wraps it with createEstreeDetector, caches the detector, and errors if neither package exists.
Test import and parser call update
test/detect-estree.test.ts
Import rolldown's parseSync helper and update the oxc parser test to use parseWithRolldownOxc(...).program with sourceType: 'module'.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • unjs/unimport#503: The main PR modifies the OxC integration in src/detect-oxc.ts; this change extends that work by preferring rolldown when available.

Suggested reviewers

  • antfu

Poem

🐰 A parser that picks its own fate,
Rolldown or oxc—both first-rate,
Lazily loaded on demand,
Cached and ready, snug and planned,
A rabbit cheers this tidy state.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding support for using rolldown/utils for parsing, which aligns with the PR's primary objective of avoiding duplicate oxc-parser installations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rolldown

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@danielroe danielroe requested a review from antfu May 13, 2026 08:53
@danielroe danielroe changed the title feat: support using rolldown/utils feat: support using rolldown/utils for parsing May 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm-workspace.yaml`:
- Line 32: Move the catalog key "rolldown" so it appears immediately after the
"pkg-types" entry to restore alphabetical ordering; edit the list where
"rolldown" currently sits and cut/paste it to follow the "pkg-types" key,
preserving the existing version string ("^1.0.0") and indentation/formatting.

In `@src/detect-oxc.ts`:
- Around line 1-2: The import order is wrong — alphabetically sort the top
imports so the `estree` import comes before `magic-string`; specifically swap or
reorder the two import statements that bring in `Program` (from 'estree') and
`MagicString` (from 'magic-string') so the `import type { Program } from
'estree'` line appears before `import type MagicString from 'magic-string'`.

In `@test/detect-estree.test.ts`:
- Around line 21-23: Duplicate test suite name: change the second call to
testWith('oxc', code => parseWithRolldownOxc(...).program as Program) to use a
distinct name (e.g., testWith('oxc-module', ...) or similar) so the two suites
are unique; update the string literal passed to testWith while leaving the
callback and parseWithRolldownOxc invocation unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 44151a1d-6889-4080-bb74-bde2d650b88f

📥 Commits

Reviewing files that changed from the base of the PR and between 68572cf and 3e69045.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • README.md
  • package.json
  • pnpm-workspace.yaml
  • src/detect-oxc.ts
  • test/detect-estree.test.ts

Comment thread pnpm-workspace.yaml Outdated
Comment thread src/detect-oxc.ts Outdated
Comment on lines +21 to +23
testWith('oxc', code => parseWithRolldownOxc('', code, {
sourceType: 'module',
}).program as Program)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix duplicate test suite name.

Both line 17 and line 21 call testWith('oxc', ...), creating duplicate test suite names detect-oxc. The second test should use a distinct name to avoid confusion and potential test framework issues.

🧪 Proposed fix
-testWith('oxc', code => parseWithRolldownOxc('', code, {
+testWith('rolldown', code => parseWithRolldownOxc('', code, {
   sourceType: 'module',
 }).program as Program)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
testWith('oxc', code => parseWithRolldownOxc('', code, {
sourceType: 'module',
}).program as Program)
testWith('rolldown', code => parseWithRolldownOxc('', code, {
sourceType: 'module',
}).program as Program)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/detect-estree.test.ts` around lines 21 - 23, Duplicate test suite name:
change the second call to testWith('oxc', code =>
parseWithRolldownOxc(...).program as Program) to use a distinct name (e.g.,
testWith('oxc-module', ...) or similar) so the two suites are unique; update the
string literal passed to testWith while leaving the callback and
parseWithRolldownOxc invocation unchanged.

@danielroe

Copy link
Copy Markdown
Member Author

@copilot would you please reorder the imports so the lint passes 🙏❤️

Agent-Logs-Url: https://github.com/unjs/unimport/sessions/c34b71d6-1326-4748-aa01-f64e78f5463a

Co-authored-by: danielroe <28706372+danielroe@users.noreply.github.com>

Copilot AI commented May 13, 2026

Copy link
Copy Markdown
Contributor

@copilot would you please reorder the imports so the lint passes 🙏❤️

Done in f62c1ef — I reordered the imports (and sorted the related YAML key order) so lint now passes.

@antfu antfu merged commit 53a9666 into main May 14, 2026
4 checks passed
@antfu antfu deleted the feat/rolldown branch May 14, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants