-
-
Notifications
You must be signed in to change notification settings - Fork 773
feat: lib chunks #3849
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
feat: lib chunks #3849
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded@pi0 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 55 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRefactors chunk naming: adds Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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 |
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: 0
🧹 Nitpick comments (1)
src/build/vite/rollup.ts (1)
70-70: Consider removing the commented-out code.The commented
sanitizeFileName: sanitizeFilePathline should either be removed entirely or include a brief comment explaining why it's retained (e.g., for future reference or pending upstream support).- // sanitizeFileName: sanitizeFilePath,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/build/chunks.ts(2 hunks)src/build/rolldown/config.ts(2 hunks)src/build/rollup/config.ts(2 hunks)src/build/vite/rollup.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/build/rolldown/config.ts (1)
src/build/chunks.ts (3)
getChunkName(15-83)NODE_MODULES_RE(6-6)libChunkName(8-13)
src/build/chunks.ts (1)
src/types/nitro.ts (1)
Nitro(16-37)
src/build/rollup/config.ts (1)
src/build/chunks.ts (3)
getChunkName(15-83)NODE_MODULES_RE(6-6)libChunkName(8-13)
src/build/vite/rollup.ts (1)
src/build/chunks.ts (3)
getChunkName(15-83)NODE_MODULES_RE(6-6)libChunkName(8-13)
⏰ 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). (2)
- GitHub Check: tests-rollup (ubuntu-latest)
- GitHub Check: tests-rollup (windows-latest)
🔇 Additional comments (7)
src/build/rolldown/config.ts (1)
56-59: LGTM! Clean implementation of lib chunking for Rolldown.The
advancedChunksconfiguration correctly usesNODE_MODULES_REto identify node_modules andlibChunkNameto generate consistent chunk names. This aligns well with the PR objective of separating bundled dependencies into distinct chunks.src/build/rollup/config.ts (1)
74-85: LGTM! Consistent lib chunking implementation for Rollup.The
manualChunkshook correctly mirrors the Rolldown implementation using Rollup's native API. The pattern of testing withNODE_MODULES_REand returninglibChunkName(id)ensures consistent chunk naming across both bundlers.src/build/vite/rollup.ts (1)
45-63: LGTM! Correct conditional chunking for Vite's dual bundler support.The implementation properly handles both Rolldown (using
advancedChunks) and standard Rollup (usingmanualChunks) paths. The logic is consistent with the standalone config files.src/build/chunks.ts (4)
6-13: LGTM! Well-designed regex patterns for node_modules handling.The
NODE_MODULES_REcorrectly excludes hidden directories (like.bin,.cache) by requiring a non-dot character after the separator. ThelibChunkNameregex properly handles both scoped (@scope/package) and unscoped packages with a sensible fallback to"common".
15-30: Clear chunk categorization with early returns.The known-group handling for
_libs/prefix androlldown-runtimeprovides clean early exits before the more complex classification logic. The emptymoduleIdsguard is a sensible defensive check.
85-96: Route path sanitization looks reasonable.The
routeToFsPathfunction handles dynamic route segments (:param,*wildcard) by converting them to$prefixes, and sanitizes other special characters. The fallback to"index"for root routes is appropriate.
64-80: Verify bundler ordering guarantees for handler matching.The logic using
ids.at(-1)assumes the last non-virtual module ID in a chunk corresponds to the handler entry point. This assumption is unvalidated since the handler matching logic was newly introduced in the recent chunk naming refactor. Confirm whether Rollup/Rolldown guarantee module ordering such that entry-point handlers consistently appear as the last module in their chunks, or add defensive checks (e.g., match against any module ID in the chunk, not just the last).
commit: |
With introduction of bundling by default in next release, libs (node_module dependnecies) are bundled by default which is more efficient thant tracing as libs are tree-shaken but making debugging harder with chunk groups containing both user code and libraries.
One solution is to simply use better chunk names but it still has issue of mixed code. This PR uses chunk groups to explicitly seperate each bundled dependency by name.
This change will also be useful in the future for low-effort bundle analysis.