fix(unplugin): avoid Iterator helpers for Node 20 compat#2635
fix(unplugin): avoid Iterator helpers for Node 20 compat#2635posva merged 1 commit intovuejs:mainfrom
Conversation
✅ Deploy Preview for vue-router canceled.
|
📝 WalkthroughWalkthroughThe change fixes a Node.js 20 compatibility issue in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/router/src/unplugin/core/tree.ts (1)
626-638: Prefernodes.lengthfor duplicate detection (Line 627).
nodesis an array;Object.keys(nodes).lengthallocates and is less idiomatic.nodes.lengthis clearer and avoids surprises if the array ever becomes sparse.♻️ Suggested change
- const dups = Array.from(seen.values()) - .filter(nodes => Object.keys(nodes).length > 1) + const dups = Array.from(seen.values()) + .filter(nodes => nodes.length > 1)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/router/src/unplugin/core/tree.ts` around lines 626 - 638, The duplicate-detection is using Object.keys(nodes).length on the array `nodes` inside the `dups` computation; change that to use `nodes.length > 1` for clarity and performance. Update the filter in the `dups` pipeline (the block using `seen.values()` and mapping to `nodes.toSorted(...)`) to check `nodes.length > 1` instead of `Object.keys(nodes).length > 1`, leaving the rest of the logic involving `nodes`, `seen`, and `treeNodes` unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/router/src/unplugin/core/tree.ts`:
- Around line 626-638: The duplicate-detection is using
Object.keys(nodes).length on the array `nodes` inside the `dups` computation;
change that to use `nodes.length > 1` for clarity and performance. Update the
filter in the `dups` pipeline (the block using `seen.values()` and mapping to
`nodes.toSorted(...)`) to check `nodes.length > 1` instead of
`Object.keys(nodes).length > 1`, leaving the rest of the logic involving
`nodes`, `seen`, and `treeNodes` unchanged.
|
Thanks! |
Closes #2633
Summary by CodeRabbit