perf(build): only cross-resolve internal aliases#4371
Conversation
|
@TheAlexLichter is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesresolveAliases Refactor and Test
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/unit/build-config.test.ts (1)
5-23: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winAdd a regression case where an internal alias points to a scoped package path.
This test doesn’t currently lock the “scoped package aliases should not participate in internal resolution” behavior. Adding one input like
"#ext": "@scope/package/subpath"and asserting it stays unchanged would prevent this class of regression.Suggested test extension
expect( resolveAliases({ "~": "/root", "@": "/root", "`#app`": "`@/app`", "`#build`": "`#app/build`", + "`#ext`": "`@scope/package/subpath`", package: "/node_modules/package", "`@scope/package`": "/node_modules/@scope/package", }) ).toEqual({ "`@scope/package`": "/node_modules/@scope/package", "`#build`": "/root/app/build", + "`#ext`": "`@scope/package/subpath`", package: "/node_modules/package", "`#app`": "/root/app", "~": "/root", "@": "/root", });🤖 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/unit/build-config.test.ts` around lines 5 - 23, The test for the resolveAliases function is missing a regression case to verify that internal aliases pointing to scoped package paths are not processed during resolution. Add a new input to the test object passed to resolveAliases with a key like "`#ext`" that maps to a scoped package path value such as "`@scope/package/subpath`", and then add the corresponding assertion in the expected output object to verify that this alias remains unchanged in the result. This ensures the function does not accidentally attempt to resolve scoped package paths within internal alias definitions.
🤖 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 `@src/build/config.ts`:
- Around line 106-113: The issue is that scoped package aliases (those starting
with "@") are being classified as resolvable by the isResolvableAlias function,
causing them to be included in the resolvableAliases array when they should be
skipped entirely to match the stated intent. Update the isResolvableAlias
function to explicitly exclude scoped packages by checking if the alias starts
with "@" and returning false for those cases, which will prevent unnecessary
comparisons in the inner loop at lines 106 and 125 and properly filter out all
package aliases regardless of scope.
---
Nitpick comments:
In `@test/unit/build-config.test.ts`:
- Around line 5-23: The test for the resolveAliases function is missing a
regression case to verify that internal aliases pointing to scoped package paths
are not processed during resolution. Add a new input to the test object passed
to resolveAliases with a key like "`#ext`" that maps to a scoped package path
value such as "`@scope/package/subpath`", and then add the corresponding assertion
in the expected output object to verify that this alias remains unchanged in the
result. This ensures the function does not accidentally attempt to resolve
scoped package paths within internal alias definitions.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 52316a9b-fad7-4ef4-a936-5fcb31e01c03
📒 Files selected for processing (2)
src/build/config.tstest/unit/build-config.test.ts
Generalize internal-alias detection so all-`@` prefixes (`@`, `@@`) are cross-resolved like `~`/`~~`/`#`, while still excluding scoped packages (`@scope/pkg`). Fixes `~~` vs `@@` asymmetry and adds a regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pi0
left a comment
There was a problem hiding this comment.
Thnx! Only fixed to keep supporting @@
This PR skips package aliases that cannot participate in Nitro’s internal alias resolution, reducing unnecessary nested comparisons. It preserves
~,@, and#alias behavior while leaving package aliases unchanged, with regression coverage. Benchmarks show improvements from roughly 3× on small alias sets to 48× on large sets.