Skip to content

Commit 135cbab

Browse files
committed
feat: expose internal mergeRouteRecord
1 parent fdd2928 commit 135cbab

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/router/src/experimental/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ export {
3939

4040
export { miss, MatchMiss } from './route-resolver/matchers/errors'
4141

42+
/**
43+
* Internal functions and types for the experimental router.
44+
* They should all be prefixed with `_` to avoid conflicts with the public API.
45+
*/
46+
47+
export { mergeRouteRecord as _mergeRouteRecord } from './router'
48+
4249
// in the new experimental router, there are only parents
4350
// this should create type errors if someone is realying on children
4451
declare module 'vue-router' {

packages/router/src/experimental/router.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,27 @@ export function normalizeRouteRecord(
370370
| EXPERIMENTAL_RouteRecordNormalized_Group
371371
}
372372

373+
/**
374+
* Merges route record objects for the experimental resolver format.
375+
* This function is specifically designed to work with objects that will be passed to normalizeRouteRecord().
376+
*
377+
* @internal
378+
*
379+
* @param main - main route record object
380+
* @param routeRecords - route records to merge (from definePage imports)
381+
* @returns merged route record object
382+
*/
383+
export function mergeRouteRecord(
384+
main: EXPERIMENTAL_RouteRecordNormalized,
385+
// TODO: actual type
386+
...routeRecords: Partial<EXPERIMENTAL_RouteRecordNormalized>[]
387+
) {
388+
for (const record of routeRecords) {
389+
main.meta = { ...main.meta, ...record.meta }
390+
}
391+
return main
392+
}
393+
373394
// TODO: probably need some generic types
374395
// <TResolver extends NEW_RouterResolver_Base>,
375396
/**

0 commit comments

Comments
 (0)