-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(auto-resolver): add auto-resolver
subpackage export with types only
#2556
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
commit: |
✅ Deploy Preview for vue-router canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2556 +/- ##
=======================================
Coverage 89.61% 89.61%
=======================================
Files 46 46
Lines 4103 4103
Branches 1090 1090
=======================================
Hits 3677 3677
Misses 421 421
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughAdds a new public export entry "./auto-resolver" in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant Router as EXPERIMENTAL_Router
participant AutoResolver as Auto‑Resolver Module
participant HMR as Vite HMR
App->>Router: initialize()
Router->>AutoResolver: import resolver
Note right of AutoResolver: exports `resolver` (types from vue-router/experimental)
AutoResolver-->>Router: provide resolver
HMR->>AutoResolver: file change detected
Note right of AutoResolver: call handleHotUpdate(router)
AutoResolver->>Router: handleHotUpdate(router)
Router-->>App: update routes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/router/package.json
(2 hunks)packages/router/vue-router-auto-resolver.d.mts
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-11T15:22:32.526Z
Learnt from: posva
PR: vuejs/router#2415
File: packages/router/src/experimental/index.ts:43-44
Timestamp: 2025-08-11T15:22:32.526Z
Learning: In the Vue Router codebase, files within the src directory should not import from src/index to avoid circular dependencies. Deep imports like `../matcher/types` are intentional and necessary for maintaining proper dependency hierarchy.
Applied to files:
packages/router/package.json
⏰ 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). (1)
- GitHub Check: build
🔇 Additional comments (1)
packages/router/vue-router-auto-resolver.d.mts (1)
1-16
: Declarations look goodThe typings line up with the experimental router APIs and expose the expected surface for the auto resolver. 👍
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 (2)
packages/router/vue-router-auto-resolver.d.mts (2)
1-18
: Prefer top-level exports over an ambientdeclare module
for a subpath mapped viaexports.types
.Since
./auto-resolver
is directly pointed to this file viapackage.json
exports, defining the module with top-level exports is cleaner and avoids ambient-module quirks. It also makes it easier for editors and aligns with common patterns (e.g., vue/macros). Add a brief note that this is a types-only subpath to prevent runtime import mistakes.Apply this diff:
-declare module 'vue-router/auto-resolver' { - import type { - EXPERIMENTAL_Router, - EXPERIMENTAL_RouterOptions, - } from 'vue-router/experimental' - - /** - * Handles HMR. - * Generated by unplugin-vue-router - */ - export function handleHotUpdate(router: EXPERIMENTAL_Router): void - - /** - * Custom resolver automatically generated at build time - * Generated by unplugin-vue-router - */ - export const resolver: EXPERIMENTAL_RouterOptions['resolver'] -} +import type { + EXPERIMENTAL_Router, + EXPERIMENTAL_RouterOptions, +} from 'vue-router/experimental' + +/** + * Handles HMR. + * Generated by unplugin-vue-router. + * NOTE: This subpath is types-only. Use `import type` and do not import at runtime. + */ +export function handleHotUpdate(router: EXPERIMENTAL_Router): void + +/** + * Custom resolver automatically generated at build time. + * Generated by unplugin-vue-router. + */ +export const resolver: EXPERIMENTAL_RouterOptions['resolver']
17-18
: Add a named type alias for ergonomics.Exporting a type alias makes it explicit how to consume this subpath safely via
import type
, reducing accidental runtime imports.Apply this diff:
export const resolver: EXPERIMENTAL_RouterOptions['resolver'] + +export type AutoResolver = EXPERIMENTAL_RouterOptions['resolver']
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/router/vue-router-auto-resolver.d.mts
(1 hunks)
⏰ 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). (1)
- GitHub Check: build
🔇 Additional comments (1)
packages/router/vue-router-auto-resolver.d.mts (1)
2-5
: Confirm upstream experimental exports
Package.json exports and files entry for./auto-resolver
are correct; verify thatvue-router/experimental
actually exportsEXPERIMENTAL_Router
andEXPERIMENTAL_RouterOptions
upstream to avoid downstream type resolution issues.
oh, I didn't notice you made the changes, I checked this PR with a repo here: userquin/vue-router-pr-2415#1 |
vue-router/auto-resolver

Summary by CodeRabbit