Skip to content

Conversation

userquin
Copy link
Member

@userquin userquin commented Sep 19, 2025

vue-router/auto-resolver
auto-resolver subpacke export

Summary by CodeRabbit

  • New Features
    • Exposed an auto-resolver for Vue Router to simplify integration and enable hot-update support.
  • Documentation/Types
    • Added TypeScript declarations for the auto-resolver and hot-update wiring to improve IDE IntelliSense and type safety.
  • Chores
    • Updated package metadata to publish the new export and its type definitions.

Copy link

pkg-pr-new bot commented Sep 19, 2025

Open in StackBlitz

npm i https://pkg.pr.new/vue-router@2556

commit: 45b6842

Copy link

netlify bot commented Sep 19, 2025

Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit 45b6842
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/68d565ddb122b10008ab22d1

Copy link

codecov bot commented Sep 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.61%. Comparing base (1885046) to head (45b6842).
⚠️ Report is 4 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

coderabbitai bot commented Sep 25, 2025

Walkthrough

Adds a new public export entry "./auto-resolver" in packages/router/package.json pointing to vue-router-auto-resolver.d.mts and includes that file in the package files. Introduces packages/router/vue-router-auto-resolver.d.mts declaring handleHotUpdate and a resolver typed against vue-router/experimental.

Changes

Cohort / File(s) Summary
Package export & published files
packages/router/package.json
Adds exports["./auto-resolver"] with types: "./vue-router-auto-resolver.d.mts" and adds "vue-router-auto-resolver.d.mts" to the files array.
Vue Router auto-resolver types
packages/router/vue-router-auto-resolver.d.mts
New TypeScript declaration module exporting handleHotUpdate(router: EXPERIMENTAL_Router): void and resolver: EXPERIMENTAL_RouterOptions['resolver']; imports EXPERIMENTAL_Router and EXPERIMENTAL_RouterOptions from vue-router/experimental.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my whiskers at a tiny export,
A resolver hops in, tidy and short.
Hot-update thumps, I sniff the code,
Types in a burrow, neat and stowed.
Routes refreshed — carrot rewards await! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the addition of the auto-resolver subpackage export with types only, accurately reflecting the primary change without extraneous detail or noise.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
Contributor

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1885046 and e9dc56c.

📒 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 good

The typings line up with the experimental router APIs and expose the expected surface for the auto resolver. 👍

Copy link
Contributor

@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 (2)
packages/router/vue-router-auto-resolver.d.mts (2)

1-18: Prefer top-level exports over an ambient declare module for a subpath mapped via exports.types.

Since ./auto-resolver is directly pointed to this file via package.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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f1a37a and 45b6842.

📒 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 that vue-router/experimental actually exports EXPERIMENTAL_Router and EXPERIMENTAL_RouterOptions upstream to avoid downstream type resolution issues.

@userquin
Copy link
Member Author

oh, I didn't notice you made the changes, I checked this PR with a repo here: userquin/vue-router-pr-2415#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants