]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat(hmr): replace resolver
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 21 Aug 2025 14:20:58 +0000 (16:20 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 21 Aug 2025 14:20:58 +0000 (16:20 +0200)
packages/router/src/experimental/router.ts

index f7a3caeab37886af7ed11c24ddea19a8e1d8a793..b5db8b0e08459d4f38f0517a11f987a2acad677f 100644 (file)
@@ -568,6 +568,17 @@ export interface EXPERIMENTAL_Router
    * Original options object passed to create the Router
    */
   readonly options: EXPERIMENTAL_RouterOptions
+
+  /**
+   * Dev only method to replace the resolver used by the router. Used during HMR
+   *
+   * @param newResolver - new resolver to use
+   *
+   * @internal
+   */
+  _hmrReplaceResolver?: (
+    newResolver: EXPERIMENTAL_ResolverFixed<EXPERIMENTAL_RouteRecordNormalized_Matchable>
+  ) => void
 }
 
 /**
@@ -581,7 +592,7 @@ export interface EXPERIMENTAL_Router
 export function experimental_createRouter(
   options: EXPERIMENTAL_RouterOptions
 ): EXPERIMENTAL_Router {
-  const {
+  let {
     resolver,
     // TODO: document that a custom parsing can be handled with a custom param that parses the whole query
     // and adds a $query property to the params added at the root record, parent of all records
@@ -1373,6 +1384,12 @@ export function experimental_createRouter(
     )
   }
 
+  if (__DEV__) {
+    router._hmrReplaceResolver = newResolver => {
+      resolver = newResolver
+    }
+  }
+
   return router
 }