-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
refactor: nuxt-link no longer imports router options #33495
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
|
|
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33495 will not alter performanceComparing Summary
|
WalkthroughThis pull request introduces a new injection key system for communicating router hash mode state to NuxtLink components. A new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Reasoning: The changes are spread across five files with a mix of architectural patterns (injection key introduction, provider/consumer consumption pattern, module configuration changes, and test scaffolding updates). Whilst individual modifications are straightforward, the interconnected nature across multiple layers—injection definition, provider setup, consumer logic, and public API exposure in NuxtLink—requires separate reasoning for each integration point. The logic density is moderate (conditional hash link detection, navigation logic adjustments), and the heterogeneous nature of edits (not a simple repetitive refactor) demands careful verification of the injection flow and public API surface changes. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
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)
packages/nuxt/test/nuxt-link.test.ts (1)
45-45: Remove unusedgetRouterHashModemock inpackages/nuxt/test/nuxt-link.test.ts(line 45); it’s never invoked bynuxt-link.ts(which usesinject(RouterHashModeSymbol)instead).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/nuxt/src/app/components/injections.ts(1 hunks)packages/nuxt/src/app/components/nuxt-link.ts(4 hunks)packages/nuxt/src/pages/module.ts(0 hunks)packages/nuxt/src/pages/runtime/plugins/router.ts(2 hunks)packages/nuxt/test/nuxt-link.test.ts(1 hunks)
💤 Files with no reviewable changes (1)
- packages/nuxt/src/pages/module.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Follow standard TypeScript conventions and best practices
Files:
packages/nuxt/src/app/components/injections.tspackages/nuxt/test/nuxt-link.test.tspackages/nuxt/src/app/components/nuxt-link.tspackages/nuxt/src/pages/runtime/plugins/router.ts
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for core functionality using
vitest
Files:
packages/nuxt/test/nuxt-link.test.ts
🧬 Code graph analysis (2)
packages/nuxt/src/app/components/nuxt-link.ts (2)
test/mocks/router-options.ts (1)
hashMode(2-2)packages/nuxt/src/app/components/injections.ts (1)
RouterHashModeSymbol(12-12)
packages/nuxt/src/pages/runtime/plugins/router.ts (2)
packages/nuxt/src/app/components/injections.ts (1)
RouterHashModeSymbol(12-12)packages/nuxt/src/pages/build.d.ts (1)
hashMode(4-4)
🔇 Additional comments (6)
packages/nuxt/src/pages/runtime/plugins/router.ts (1)
23-23: LGTM!The import and provide statements correctly expose the router hash mode to downstream components via Vue's injection mechanism. The placement after router installation is appropriate.
Also applies to: 99-100
packages/nuxt/src/app/components/injections.ts (1)
11-12: LGTM!The injection key is properly typed and follows the existing pattern in the file.
packages/nuxt/src/app/components/nuxt-link.ts (4)
25-25: LGTM!The injection of
RouterHashModeSymbolwith a default value offalseprovides a safe fallback, and theisHashLinkWithoutHashModehelper correctly identifies hash-only links when hash mode is disabled.Also applies to: 208-212
217-217: LGTM!The conditional correctly prevents hash-only links from being processed when hash mode is disabled, ensuring they're treated as external links.
248-248: LGTM!The
isHashLinkWithoutHashModehelper is correctly exposed in the public API with proper type annotations.Also applies to: 254-254
360-360: LGTM!The rendering logic correctly prevents
RouterLinkfrom mounting for hash-only links when hash mode is disabled, ensuring they're rendered as standard anchor tags instead.Also applies to: 427-427
| } | ||
| nuxtApp.vueApp.use(router) | ||
|
|
||
| nuxtApp.vueApp.provide(RouterHashModeSymbol, hashMode) |
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.
rather than using provide, I'd prefer to use a virtual module, if we can. it keeps it tree-shakeable and isn't dependent on the context.
🔗 Linked issue
Not yet
📚 Description
Remove the import to
#build/router.optionsfrom NuxtLink