Skip to content

Conversation

@sxzz
Copy link
Contributor

@sxzz sxzz commented Dec 17, 2025

Use native magic-string for Rolldown, see README

Summary by CodeRabbit

  • Chores
    • Updated dependencies to latest versions.
    • Internal infrastructure improvements.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Walkthrough

Updated package dependencies: added rolldown-string, bumped tsdown version. Refactored auto-exports handler to use withMagicString wrapper instead of manual MagicString instance management. Updated tsdown config type imports from Options to UserConfig.

Changes

Cohort / File(s) Summary
Dependency updates
package.json
Added rolldown-string ^0.2.1; bumped tsdown from 0.17.4 to 0.18.0 in dependencies and devDependencies.
Handler refactoring
src/data-loaders/auto-exports.ts
Replaced MagicString-based handler with withMagicString-wrapped handler; removed manual MagicString instance creation and explicit code/map returns; updated imports (removed magic-string, added withMagicString).
Type import updates
tsdown.config.ts
Changed type import from Options to UserConfig; updated type assertion from Options to UserConfig.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • src/data-loaders/auto-exports.ts: Verify withMagicString wrapper correctly handles code mapping and maintains existing logic flow for loader export extraction and appending.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: replacing MagicString-based handler with native magic-string wrapper, aligning with the refactoring shown across package.json, auto-exports.ts, and tsdown.config.ts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 17, 2025

Open in StackBlitz

npm i https://pkg.pr.new/unplugin-vue-router@771

commit: 61711e1

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.09%. Comparing base (73d02c0) to head (61711e1).

Files with missing lines Patch % Lines
src/data-loaders/auto-exports.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #771      +/-   ##
==========================================
+ Coverage   73.06%   73.09%   +0.03%     
==========================================
  Files          30       30              
  Lines        2421     2420       -1     
  Branches      847      850       +3     
==========================================
  Hits         1769     1769              
+ Misses        545      544       -1     
  Partials      107      107              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@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

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73d02c0 and 61711e1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • package.json (2 hunks)
  • src/data-loaders/auto-exports.ts (2 hunks)
  • tsdown.config.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (2)
package.json (1)

165-165: Verify package names and versions in dependencies.

rolldown-string@0.2.1 does not appear to exist on the npm registry. The latest version of tsdown is 0.17.2, not 0.18.0. Confirm the correct package names and version numbers in package.json before proceeding with security validation.

tsdown.config.ts (1)

1-1: tsdown 0.18.0 does not exist. The latest version is 0.17.2. Verify the correct tsdown version in use and confirm that UserConfig is appropriate for that version.

import { createFilter } from 'unplugin-utils'
import type { Plugin } from 'vite'
import MagicString from 'magic-string'
import { withMagicString } from 'rolldown-string'
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat -n src/data-loaders/auto-exports.ts | sed -n '1,10p'

Repository: posva/unplugin-vue-router

Length of output: 520


🏁 Script executed:

cat -n src/data-loaders/auto-exports.ts | sed -n '75,95p'

Repository: posva/unplugin-vue-router

Length of output: 708


🌐 Web query:

rolldown-string withMagicString API

💡 Result:

Short answer: there’s no widely used package named "rolldown-string". If you want the behavior (convert text files to modules) in Rolldown, implement a small plugin that uses MagicString — same pattern Rollup plugins use (transform/renderChunk returning code + sourcemap via MagicString). See MagicString docs and examples of Rollup plugins that do this.

Minimal example (conceptual):

  • import MagicString from 'magic-string'
  • in plugin transform(id, code) for matching files:
    • const s = new MagicString(code)
    • s.prepend("export default ")
    • s.append(";")
    • return { code: s.toString(), map: s.generateMap({ hires: true }) }

References:

  • MagicString (API & usage). [1]
  • Rolldown package/homepage (use same plugin hooks as Rollup). [2]
  • Example Rollup plugins using MagicString (pattern you can copy). [3]

Sources:
[1] Rich Harris — magic-string (GitHub README).
[2] rolldown package / homepage (npm).
[3] Example Rollup plugin code using MagicString (e.g., preserve-shebang / renderChunk).


rolldown-string package not found in standard documentation.

The withMagicString API from rolldown-string cannot be verified—this package does not appear in npm or standard documentation. The standard pattern for Rollup/Rolldown plugins requires explicit return of { code: s.toString(), map: s.generateMap({...}) }, not relying on automatic return value management. Either this is a custom/internal package that requires documentation, or the import path is incorrect.

🤖 Prompt for AI Agents
In src/data-loaders/auto-exports.ts around line 3, the import of withMagicString
from 'rolldown-string' is invalid/unpublished and the transform must explicitly
return { code, map }; replace the unknown import with a known approach (e.g.,
import MagicString from 'magic-string' or the correct helper package),
instantiate a MagicString for your source edits, and ensure the plugin/transform
returns an object like { code: s.toString(), map: s.generateMap({ hires: true })
}; if you intended a custom helper, add/update that module and document it and
ensure package.json includes the correct dependency.

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.

1 participant