-
-
Notifications
You must be signed in to change notification settings - Fork 110
perf: use native magic-string #771
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughUpdated 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
commit: |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis 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 thatUserConfigis appropriate for that version.
| import { createFilter } from 'unplugin-utils' | ||
| import type { Plugin } from 'vite' | ||
| import MagicString from 'magic-string' | ||
| import { withMagicString } from 'rolldown-string' |
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.
🧩 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.
Use native
magic-stringfor Rolldown, see READMESummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.