Skip to content

Conversation

@Akryum
Copy link
Contributor

@Akryum Akryum commented Oct 16, 2025

🔗 Linked issue

Not yet

📚 Description

Remove the import to #build/router.options from NuxtLink

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 16, 2025

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@33495

nuxt

npm i https://pkg.pr.new/nuxt@33495

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@33495

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@33495

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@33495

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@33495

commit: e47091c

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 16, 2025

CodSpeed Performance Report

Merging #33495 will not alter performance

Comparing Akryum:split-router-options-hash-mode (e47091c) with main (7bcc4ca)

Summary

✅ 10 untouched

@Akryum Akryum marked this pull request as ready for review October 16, 2025 15:57
@Akryum Akryum requested a review from danielroe as a code owner October 16, 2025 15:57
@coderabbitai
Copy link

coderabbitai bot commented Oct 16, 2025

Walkthrough

This pull request introduces a new injection key system for communicating router hash mode state to NuxtLink components. A new RouterHashModeSymbol injection key is added and exported from the injections module. The router plugin is updated to provide this symbol via the Vue app context using the existing hash mode value. The NuxtLink component now consumes this symbol via injection to detect hash-style links when hash mode is inactive, exposing a new isHashLinkWithoutHashMode helper in its public API. The pages module removes router.options.mjs generation when pages are disabled. Test mocks are updated to include the new hash mode interface.

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)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the primary refactor of removing the import of router options from the NuxtLink component, follows conventional commit style, and clearly aligns with the main change in the changeset so that teammates can understand the key modification at a glance.
Description Check ✅ Passed The pull request description directly states the removal of the import to #build/router.options from NuxtLink, which is clearly related to the changeset, and while concise it references the specific change without being generic or off-topic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 unused getRouterHashMode mock in packages/nuxt/test/nuxt-link.test.ts (line 45); it’s never invoked by nuxt-link.ts (which uses inject(RouterHashModeSymbol) instead).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bcc4ca and fac64e6.

📒 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.ts
  • packages/nuxt/test/nuxt-link.test.ts
  • packages/nuxt/src/app/components/nuxt-link.ts
  • packages/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 RouterHashModeSymbol with a default value of false provides a safe fallback, and the isHashLinkWithoutHashMode helper 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 isHashLinkWithoutHashMode helper is correctly exposed in the public API with proper type annotations.

Also applies to: 254-254


360-360: LGTM!

The rendering logic correctly prevents RouterLink from 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)
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants