unplugin-vue-router
Advanced tools
Comparing version 0.5.4 to 0.5.5
import * as esbuild from 'esbuild'; | ||
import { O as Options } from './options-3030b9f1.js'; | ||
import { O as Options } from './options-7332b95e.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
@@ -193,2 +193,53 @@ "use strict"; | ||
} | ||
var ImportsMap = class { | ||
constructor() { | ||
// path -> import as -> import name | ||
// e.g map['vue-router']['myUseRouter'] = 'useRouter' -> import { useRouter as myUseRouter } from 'vue-router' | ||
this.map = /* @__PURE__ */ new Map(); | ||
} | ||
add(path, importEntry) { | ||
if (!this.map.has(path)) { | ||
this.map.set(path, /* @__PURE__ */ new Map()); | ||
} | ||
const imports = this.map.get(path); | ||
if (typeof importEntry === "string") { | ||
imports.set(importEntry, importEntry); | ||
} else { | ||
imports.set(importEntry.as || importEntry.name, importEntry.name); | ||
} | ||
return this; | ||
} | ||
addDefault(path, as) { | ||
return this.add(path, { name: "default", as }); | ||
} | ||
getImportList(path) { | ||
if (!this.map.has(path)) | ||
return []; | ||
return Array.from(this.map.get(path)).map(([as, name]) => ({ | ||
as: as || name, | ||
name | ||
})); | ||
} | ||
toString() { | ||
let importStatements = ""; | ||
for (const [path, imports] of this.map) { | ||
if (!imports.size) | ||
continue; | ||
if (imports.size === 1) { | ||
const [[importName, maybeDefault]] = [...imports.entries()]; | ||
if (maybeDefault === "default") { | ||
importStatements += `import ${importName} from '${path}' | ||
`; | ||
continue; | ||
} | ||
} | ||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from '${path}' | ||
`; | ||
} | ||
return importStatements; | ||
} | ||
get size() { | ||
return this.map.size; | ||
} | ||
}; | ||
@@ -623,6 +674,6 @@ // src/core/treeNodeValue.ts | ||
// src/codegen/generateRouteRecords.ts | ||
function generateRouteRecord(node, options, importList, indent = 0) { | ||
function generateRouteRecord(node, options, importsMap, indent = 0) { | ||
if (node.value.path === "/" && indent === 0) { | ||
return `[ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 1)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 1)).join(",\n")} | ||
]`; | ||
@@ -641,3 +692,3 @@ } | ||
options.importMode, | ||
importList | ||
importsMap | ||
) : "/* no component */"} | ||
@@ -648,3 +699,3 @@ ${overrides.props != null ? indentStr + `props: ${overrides.props}, | ||
indentStr}${node.children.size > 0 ? `children: [ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 2)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 2)).join(",\n")} | ||
${indentStr}],` : "/* no children */"}${formatMeta(node, indentStr)} | ||
@@ -655,7 +706,8 @@ ${startIndent}}`; | ||
for (const [name, filePath] of node.value.components) { | ||
const pageDataImport = `_definePage_${name}_${importList.size}`; | ||
const pageDataImport = `_definePage_${name}_${importsMap.size}`; | ||
definePageDataList.push(pageDataImport); | ||
importList.set(pageDataImport, `${filePath}?definePage&vue`); | ||
importsMap.addDefault(`${filePath}?definePage&vue`, pageDataImport); | ||
} | ||
if (definePageDataList.length) { | ||
importsMap.add("unplugin-vue-router/runtime", "_mergeRouteRecord"); | ||
return ` _mergeRouteRecord( | ||
@@ -669,6 +721,6 @@ ${routeRecord}, | ||
} | ||
function generateRouteRecordComponent(node, indentStr, importMode, importList) { | ||
function generateRouteRecordComponent(node, indentStr, importMode, importsMap) { | ||
const files = Array.from(node.value.components); | ||
const isDefaultExport = files.length === 1 && files[0][0] === "default"; | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importList)},` : ( | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importsMap)},` : ( | ||
// files has at least one entry | ||
@@ -680,3 +732,3 @@ `components: { | ||
importMode, | ||
importList | ||
importsMap | ||
)}` | ||
@@ -687,3 +739,3 @@ ).join(",\n")} | ||
} | ||
function generatePageImport(filepath, importMode, importList) { | ||
function generatePageImport(filepath, importMode, importsMap) { | ||
const mode = typeof importMode === "function" ? importMode(filepath) : importMode; | ||
@@ -693,4 +745,4 @@ if (mode === "async") { | ||
} else { | ||
const importName = `_page_${importList.size}`; | ||
importList.set(importName, filepath); | ||
const importName = `_page_${importsMap.size}`; | ||
importsMap.addDefault(filepath, importName); | ||
return importName; | ||
@@ -856,3 +908,3 @@ } | ||
_DefineLoaderOptions, | ||
} from 'unplugin-vue-router' | ||
} from 'unplugin-vue-router/types' | ||
@@ -917,3 +969,3 @@ declare module '${routesModule}' { | ||
export const RouterLink: RouterLinkTyped<RouteNamedMap> | ||
// Experimental Data Fetching | ||
@@ -1261,2 +1313,11 @@ | ||
/** | ||
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method | ||
* **only returns direct children**. | ||
*/ | ||
get children() { | ||
return [...this.node.children.values()].map( | ||
(node) => new EditableTreeNode(node) | ||
); | ||
} | ||
/** | ||
* DFS traversal of the tree. | ||
@@ -1407,17 +1468,12 @@ * @example | ||
function generateRoutes() { | ||
const importList = /* @__PURE__ */ new Map(); | ||
const importsMap = new ImportsMap(); | ||
const routesExport = `export const routes = ${generateRouteRecord( | ||
routeTree, | ||
options, | ||
importList | ||
importsMap | ||
)}`; | ||
let imports = ""; | ||
if (true) { | ||
imports += `import { _HasDataLoaderMeta, _mergeRouteRecord } from 'unplugin-vue-router/runtime' | ||
`; | ||
if (options.dataFetching) { | ||
importsMap.add("unplugin-vue-router/runtime", "_HasDataLoaderMeta"); | ||
} | ||
for (const [name, path] of importList) { | ||
imports += `import ${name} from '${path}' | ||
`; | ||
} | ||
let imports = `${importsMap}`; | ||
if (imports) { | ||
@@ -1424,0 +1480,0 @@ imports += "\n"; |
import * as unplugin from 'unplugin'; | ||
import { R as ResolvedOptions, S as ServerContext, L as LiteralStringUnion, O as Options } from './options-3030b9f1.js'; | ||
export { E as EditableTreeNode, T as TreeNode, d as TreeNodeValueParam, e as TreeNodeValueStatic, c as createPrefixTree, b as createTreeNodeValue, g as getFileBasedRouteName, a as getPascalCaseRouteName } from './options-3030b9f1.js'; | ||
import { RouteParamsRaw, RouteParams, RouteMeta, RouteLocationNormalized, RouteRecordName, RouteLocationNormalizedLoaded, RouteQueryAndHash, RouteLocationOptions, RouteLocation, NavigationGuardNext, NavigationFailure, Router, RouteLocationRaw, RouterLinkProps as RouterLinkProps$1 } from 'vue-router'; | ||
import { Ref, AllowedComponentProps, ComponentCustomProps, VNodeProps, UnwrapRef, VNode, ComputedRef } from 'vue'; | ||
import { R as ResolvedOptions, S as ServerContext, O as Options } from './options-7332b95e.js'; | ||
export { D as DEFAULT_OPTIONS, E as EditableTreeNode, T as TreeNode, d as TreeNodeValueParam, e as TreeNodeValueStatic, c as createPrefixTree, b as createTreeNodeValue, g as getFileBasedRouteName, a as getPascalCaseRouteName } from './options-7332b95e.js'; | ||
export { N as NavigationGuard, P as ParamValue, q as ParamValueOneOrMore, r as ParamValueZeroOrMore, s as ParamValueZeroOrOne, c as RouteLocationAsPathTyped, d as RouteLocationAsPathTypedList, a as RouteLocationAsRelativeTyped, b as RouteLocationAsRelativeTypedList, e as RouteLocationAsString, l as RouteLocationNormalizedLoadedTyped, m as RouteLocationNormalizedLoadedTypedList, j as RouteLocationNormalizedTyped, k as RouteLocationNormalizedTypedList, h as RouteLocationResolvedTyped, i as RouteLocationResolvedTypedList, f as RouteLocationTyped, g as RouteLocationTypedList, R as RouteRecordInfo, o as RouterLinkTyped, U as UseLinkFnTyped, _ as _RouteMapGeneric, n as _RouterTyped, p as _UseLinkReturnTyped } from './generateRouteParams-c0f03f51.js'; | ||
export { a as _DataLoader, D as _DefineLoaderOptions } from './defineLoader-bde635fd.js'; | ||
import 'vue-router'; | ||
import 'vue'; | ||
@@ -18,136 +19,2 @@ declare function createRoutesContext(options: ResolvedOptions): { | ||
interface RouteRecordInfo<Name extends string = string, Path extends string = string, ParamsRaw extends RouteParamsRaw = RouteParamsRaw, Params extends RouteParams = RouteParams, Meta extends RouteMeta = RouteMeta> { | ||
name: Name; | ||
path: Path; | ||
paramsRaw: ParamsRaw; | ||
params: Params; | ||
meta: Meta; | ||
} | ||
type _RouteMapGeneric = Record<string, RouteRecordInfo>; | ||
interface RouteLocationNormalizedTyped<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>, Name extends keyof RouteMap = keyof RouteMap> extends RouteLocationNormalized { | ||
name: Extract<Name, RouteRecordName>; | ||
params: RouteMap[Name]['params']; | ||
} | ||
type RouteLocationNormalizedTypedList<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>> = { | ||
[N in keyof RouteMap]: RouteLocationNormalizedTyped<RouteMap, N>; | ||
}; | ||
interface RouteLocationNormalizedLoadedTyped<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>, Name extends keyof RouteMap = keyof RouteMap> extends RouteLocationNormalizedLoaded { | ||
name: Extract<Name, RouteRecordName>; | ||
params: RouteMap[Name]['params']; | ||
} | ||
type RouteLocationNormalizedLoadedTypedList<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>> = { | ||
[N in keyof RouteMap]: RouteLocationNormalizedLoadedTyped<RouteMap, N>; | ||
}; | ||
interface RouteLocationAsRelativeTyped<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>, Name extends keyof RouteMap = keyof RouteMap> extends RouteQueryAndHash, RouteLocationOptions { | ||
name?: Name; | ||
params?: RouteMap[Name]['paramsRaw']; | ||
} | ||
type RouteLocationAsRelativeTypedList<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>> = { | ||
[N in keyof RouteMap]: RouteLocationAsRelativeTyped<RouteMap, N>; | ||
}; | ||
interface RouteLocationAsPathTyped<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>, Name extends keyof RouteMap = keyof RouteMap> extends RouteQueryAndHash, RouteLocationOptions { | ||
path: LiteralStringUnion<RouteMap[Name]['path']>; | ||
} | ||
type RouteLocationAsPathTypedList<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>> = { | ||
[N in keyof RouteMap]: RouteLocationAsPathTyped<RouteMap, N>; | ||
}; | ||
type RouteLocationAsString<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>> = LiteralStringUnion<RouteMap[keyof RouteMap]['path'], string>; | ||
interface RouteLocationTyped<RouteMap extends _RouteMapGeneric, Name extends keyof RouteMap> extends RouteLocation { | ||
name: Extract<Name, RouteRecordName>; | ||
params: RouteMap[Name]['params']; | ||
} | ||
type RouteLocationTypedList<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>> = { | ||
[N in keyof RouteMap]: RouteLocationTyped<RouteMap, N>; | ||
}; | ||
interface RouteLocationResolvedTyped<RouteMap extends _RouteMapGeneric, Name extends keyof RouteMap> extends RouteLocationTyped<RouteMap, Name> { | ||
href: string; | ||
} | ||
type RouteLocationResolvedTypedList<RouteMap extends _RouteMapGeneric = Record<string, RouteRecordInfo>> = { | ||
[N in keyof RouteMap]: RouteLocationResolvedTyped<RouteMap, N>; | ||
}; | ||
type NavigationGuardReturn<RouteMap extends _RouteMapGeneric> = void | boolean | RouteLocationAsString<RouteMap> | RouteLocationAsRelativeTypedList<RouteMap>[keyof RouteMap] | RouteLocationAsPathTypedList<RouteMap>[keyof RouteMap]; | ||
interface NavigationGuardWithThis<T, RouteMap extends _RouteMapGeneric> { | ||
(this: T, to: RouteLocationNormalizedTypedList<RouteMap>[keyof RouteMap], from: RouteLocationNormalizedLoadedTypedList<RouteMap>[keyof RouteMap], next: NavigationGuardNext): NavigationGuardReturn<RouteMap> | Promise<NavigationGuardReturn<RouteMap>>; | ||
} | ||
interface NavigationGuard<RouteMap extends _RouteMapGeneric> { | ||
(to: RouteLocationNormalizedTypedList<RouteMap>[keyof RouteMap], from: RouteLocationNormalizedLoadedTypedList<RouteMap>[keyof RouteMap], next: NavigationGuardNext): NavigationGuardReturn<RouteMap> | Promise<NavigationGuardReturn<RouteMap>>; | ||
} | ||
interface NavigationHookAfter<RouteMap extends _RouteMapGeneric = _RouteMapGeneric> { | ||
(to: RouteLocationNormalizedTypedList<RouteMap>[keyof RouteMap], from: RouteLocationNormalizedLoadedTypedList<RouteMap>[keyof RouteMap], failure?: NavigationFailure | void): any; | ||
} | ||
interface _RouterTyped<RouteMap extends _RouteMapGeneric = _RouteMapGeneric> extends Omit<Router, 'resolve' | 'push' | 'replace' | 'beforeEach' | 'beforeResolve' | 'afterEach'> { | ||
currentRoute: Ref<RouteLocationNormalizedLoadedTypedList<RouteMap>[keyof RouteMap]>; | ||
push<Name extends keyof RouteMap = keyof RouteMap>(to: RouteLocationAsString<RouteMap> | RouteLocationAsRelativeTyped<RouteMap, Name> | RouteLocationAsPathTyped<RouteMap, Name>): ReturnType<Router['push']>; | ||
replace<Name extends keyof RouteMap = keyof RouteMap>(to: RouteLocationAsString<RouteMap> | RouteLocationAsRelativeTyped<RouteMap, Name> | RouteLocationAsPathTyped<RouteMap, Name>): ReturnType<Router['replace']>; | ||
resolve<Name extends keyof RouteMap = keyof RouteMap>(to: RouteLocationAsString<RouteMap> | RouteLocationAsRelativeTyped<RouteMap, Name> | RouteLocationAsPathTyped<RouteMap, Name>, currentLocation?: RouteLocationNormalizedLoaded): RouteLocationResolvedTypedList<RouteMap>[Name]; | ||
beforeEach(guard: NavigationGuardWithThis<undefined, RouteMap>): ReturnType<Router['beforeEach']>; | ||
beforeResolve(guard: NavigationGuardWithThis<undefined, RouteMap>): ReturnType<Router['beforeEach']>; | ||
afterEach(guard: NavigationHookAfter<RouteMap>): ReturnType<Router['beforeEach']>; | ||
} | ||
/** | ||
* Typed version of `RouterLinkProps`. | ||
*/ | ||
interface RouterLinkProps<RouteMap extends _RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap> extends Omit<RouterLinkProps$1, 'to'> { | ||
to: RouteLocationAsString<RouteMap> | RouteLocationAsRelativeTypedList<RouteMap>[Name] | RouteLocationAsPathTypedList<RouteMap>[Name]; | ||
} | ||
/** | ||
* Typed version of `<RouterLink>` component. | ||
*/ | ||
interface RouterLinkTyped<RouteMap extends _RouteMapGeneric> { | ||
new (): { | ||
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & RouterLinkProps<RouteMap>; | ||
$slots: { | ||
default: (arg: UnwrapRef<_UseLinkReturnTyped<RouteMap>>) => VNode[]; | ||
}; | ||
}; | ||
} | ||
/** | ||
* Return type of `useLink()`. Should be exposed by the router instead. | ||
* @internal | ||
*/ | ||
interface _UseLinkReturnTyped<RouteMap extends _RouteMapGeneric, Name extends keyof RouteMap = keyof RouteMap> { | ||
route: ComputedRef<RouteLocationResolvedTypedList<RouteMap>[Name]>; | ||
href: ComputedRef<string>; | ||
isActive: ComputedRef<boolean>; | ||
isExactActive: ComputedRef<boolean>; | ||
navigate(e?: MouseEvent): Promise<void | NavigationFailure>; | ||
} | ||
/** | ||
* Typed version of `useLink()`. | ||
*/ | ||
interface UseLinkFnTyped<RouteMap extends _RouteMapGeneric> { | ||
<Name extends keyof RouteMap = keyof RouteMap>(props: { | ||
to: RouteLocationAsString<RouteMap> | RouteLocationAsRelativeTyped<RouteMap, Name> | RouteLocationAsPathTyped<RouteMap, Name> | Ref<RouteLocationRaw>; | ||
replace?: boolean | undefined | Ref<boolean | undefined>; | ||
}): _UseLinkReturnTyped<RouteMap, Name>; | ||
} | ||
/** | ||
* Utility type for raw and non raw params like :id+ | ||
* | ||
*/ | ||
type ParamValueOneOrMore<isRaw extends boolean> = [ | ||
ParamValue<isRaw>, | ||
...ParamValue<isRaw>[] | ||
]; | ||
/** | ||
* Utility type for raw and non raw params like :id* | ||
* | ||
*/ | ||
type ParamValueZeroOrMore<isRaw extends boolean> = ParamValue<isRaw>[] | undefined | null; | ||
/** | ||
* Utility type for raw and non raw params like :id? | ||
* | ||
*/ | ||
type ParamValueZeroOrOne<isRaw extends boolean> = true extends isRaw ? string | number | null | undefined : string; | ||
/** | ||
* Utility type for raw and non raw params like :id | ||
* | ||
*/ | ||
type ParamValue<isRaw extends boolean> = true extends isRaw ? string | number : string; | ||
declare const _default: unplugin.UnpluginInstance<Options | undefined, boolean>; | ||
@@ -172,2 +39,2 @@ | ||
export { NavigationGuard, Options, ParamValue, ParamValueOneOrMore, ParamValueZeroOrMore, ParamValueZeroOrOne, RouteLocationAsPathTyped, RouteLocationAsPathTypedList, RouteLocationAsRelativeTyped, RouteLocationAsRelativeTypedList, RouteLocationAsString, RouteLocationNormalizedLoadedTyped, RouteLocationNormalizedLoadedTypedList, RouteLocationNormalizedTyped, RouteLocationNormalizedTypedList, RouteLocationResolvedTyped, RouteLocationResolvedTypedList, RouteLocationTyped, RouteLocationTypedList, RouteRecordInfo, RouterLinkTyped, UseLinkFnTyped, VueRouterAutoImports, VueRouterExports, _RouteMapGeneric, _RouterTyped, _UseLinkReturnTyped, createRoutesContext, _default as default }; | ||
export { Options, VueRouterAutoImports, VueRouterExports, createRoutesContext, _default as default }; |
@@ -50,6 +50,4 @@ "use strict"; | ||
__export(src_exports, { | ||
DEFAULT_OPTIONS: () => DEFAULT_OPTIONS, | ||
EditableTreeNode: () => EditableTreeNode, | ||
TreeNode: () => TreeNode, | ||
TreeNodeValueParam: () => TreeNodeValueParam, | ||
TreeNodeValueStatic: () => TreeNodeValueStatic, | ||
VueRouterAutoImports: () => VueRouterAutoImports, | ||
@@ -222,2 +220,53 @@ VueRouterExports: () => VueRouterExports, | ||
} | ||
var ImportsMap = class { | ||
constructor() { | ||
// path -> import as -> import name | ||
// e.g map['vue-router']['myUseRouter'] = 'useRouter' -> import { useRouter as myUseRouter } from 'vue-router' | ||
this.map = /* @__PURE__ */ new Map(); | ||
} | ||
add(path, importEntry) { | ||
if (!this.map.has(path)) { | ||
this.map.set(path, /* @__PURE__ */ new Map()); | ||
} | ||
const imports = this.map.get(path); | ||
if (typeof importEntry === "string") { | ||
imports.set(importEntry, importEntry); | ||
} else { | ||
imports.set(importEntry.as || importEntry.name, importEntry.name); | ||
} | ||
return this; | ||
} | ||
addDefault(path, as) { | ||
return this.add(path, { name: "default", as }); | ||
} | ||
getImportList(path) { | ||
if (!this.map.has(path)) | ||
return []; | ||
return Array.from(this.map.get(path)).map(([as, name]) => ({ | ||
as: as || name, | ||
name | ||
})); | ||
} | ||
toString() { | ||
let importStatements = ""; | ||
for (const [path, imports] of this.map) { | ||
if (!imports.size) | ||
continue; | ||
if (imports.size === 1) { | ||
const [[importName, maybeDefault]] = [...imports.entries()]; | ||
if (maybeDefault === "default") { | ||
importStatements += `import ${importName} from '${path}' | ||
`; | ||
continue; | ||
} | ||
} | ||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from '${path}' | ||
`; | ||
} | ||
return importStatements; | ||
} | ||
get size() { | ||
return this.map.size; | ||
} | ||
}; | ||
@@ -652,6 +701,6 @@ // src/core/treeNodeValue.ts | ||
// src/codegen/generateRouteRecords.ts | ||
function generateRouteRecord(node, options, importList, indent = 0) { | ||
function generateRouteRecord(node, options, importsMap, indent = 0) { | ||
if (node.value.path === "/" && indent === 0) { | ||
return `[ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 1)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 1)).join(",\n")} | ||
]`; | ||
@@ -670,3 +719,3 @@ } | ||
options.importMode, | ||
importList | ||
importsMap | ||
) : "/* no component */"} | ||
@@ -677,3 +726,3 @@ ${overrides.props != null ? indentStr + `props: ${overrides.props}, | ||
indentStr}${node.children.size > 0 ? `children: [ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 2)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 2)).join(",\n")} | ||
${indentStr}],` : "/* no children */"}${formatMeta(node, indentStr)} | ||
@@ -684,7 +733,8 @@ ${startIndent}}`; | ||
for (const [name, filePath] of node.value.components) { | ||
const pageDataImport = `_definePage_${name}_${importList.size}`; | ||
const pageDataImport = `_definePage_${name}_${importsMap.size}`; | ||
definePageDataList.push(pageDataImport); | ||
importList.set(pageDataImport, `${filePath}?definePage&vue`); | ||
importsMap.addDefault(`${filePath}?definePage&vue`, pageDataImport); | ||
} | ||
if (definePageDataList.length) { | ||
importsMap.add("unplugin-vue-router/runtime", "_mergeRouteRecord"); | ||
return ` _mergeRouteRecord( | ||
@@ -698,6 +748,6 @@ ${routeRecord}, | ||
} | ||
function generateRouteRecordComponent(node, indentStr, importMode, importList) { | ||
function generateRouteRecordComponent(node, indentStr, importMode, importsMap) { | ||
const files = Array.from(node.value.components); | ||
const isDefaultExport = files.length === 1 && files[0][0] === "default"; | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importList)},` : ( | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importsMap)},` : ( | ||
// files has at least one entry | ||
@@ -709,3 +759,3 @@ `components: { | ||
importMode, | ||
importList | ||
importsMap | ||
)}` | ||
@@ -716,3 +766,3 @@ ).join(",\n")} | ||
} | ||
function generatePageImport(filepath, importMode, importList) { | ||
function generatePageImport(filepath, importMode, importsMap) { | ||
const mode = typeof importMode === "function" ? importMode(filepath) : importMode; | ||
@@ -722,4 +772,4 @@ if (mode === "async") { | ||
} else { | ||
const importName = `_page_${importList.size}`; | ||
importList.set(importName, filepath); | ||
const importName = `_page_${importsMap.size}`; | ||
importsMap.addDefault(filepath, importName); | ||
return importName; | ||
@@ -885,3 +935,3 @@ } | ||
_DefineLoaderOptions, | ||
} from 'unplugin-vue-router' | ||
} from 'unplugin-vue-router/types' | ||
@@ -946,3 +996,3 @@ declare module '${routesModule}' { | ||
export const RouterLink: RouterLinkTyped<RouteNamedMap> | ||
// Experimental Data Fetching | ||
@@ -1290,2 +1340,11 @@ | ||
/** | ||
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method | ||
* **only returns direct children**. | ||
*/ | ||
get children() { | ||
return [...this.node.children.values()].map( | ||
(node) => new EditableTreeNode(node) | ||
); | ||
} | ||
/** | ||
* DFS traversal of the tree. | ||
@@ -1436,17 +1495,12 @@ * @example | ||
function generateRoutes() { | ||
const importList = /* @__PURE__ */ new Map(); | ||
const importsMap = new ImportsMap(); | ||
const routesExport = `export const routes = ${generateRouteRecord( | ||
routeTree, | ||
options, | ||
importList | ||
importsMap | ||
)}`; | ||
let imports = ""; | ||
if (true) { | ||
imports += `import { _HasDataLoaderMeta, _mergeRouteRecord } from 'unplugin-vue-router/runtime' | ||
`; | ||
if (options.dataFetching) { | ||
importsMap.add("unplugin-vue-router/runtime", "_HasDataLoaderMeta"); | ||
} | ||
for (const [name, path] of importList) { | ||
imports += `import ${name} from '${path}' | ||
`; | ||
} | ||
let imports = `${importsMap}`; | ||
if (imports) { | ||
@@ -1681,6 +1735,4 @@ imports += "\n"; | ||
0 && (module.exports = { | ||
DEFAULT_OPTIONS, | ||
EditableTreeNode, | ||
TreeNode, | ||
TreeNodeValueParam, | ||
TreeNodeValueStatic, | ||
VueRouterAutoImports, | ||
@@ -1687,0 +1739,0 @@ VueRouterExports, |
@@ -1,2 +0,2 @@ | ||
export { D as DEFAULT_OPTIONS, O as Options, R as ResolvedOptions, h as RoutesFolder, f as RoutesFolderOption, S as ServerContext, i as _OptionsImportMode, _ as _RoutesFolder, r as resolveOptions } from './options-3030b9f1.js'; | ||
export { D as DEFAULT_OPTIONS, O as Options, R as ResolvedOptions, h as RoutesFolder, f as RoutesFolderOption, S as ServerContext, i as _OptionsImportMode, _ as _RoutesFolder, r as resolveOptions } from './options-7332b95e.js'; | ||
import 'vue-router'; |
import * as rollup from 'rollup'; | ||
import { O as Options } from './options-3030b9f1.js'; | ||
import { O as Options } from './options-7332b95e.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
@@ -193,2 +193,53 @@ "use strict"; | ||
} | ||
var ImportsMap = class { | ||
constructor() { | ||
// path -> import as -> import name | ||
// e.g map['vue-router']['myUseRouter'] = 'useRouter' -> import { useRouter as myUseRouter } from 'vue-router' | ||
this.map = /* @__PURE__ */ new Map(); | ||
} | ||
add(path, importEntry) { | ||
if (!this.map.has(path)) { | ||
this.map.set(path, /* @__PURE__ */ new Map()); | ||
} | ||
const imports = this.map.get(path); | ||
if (typeof importEntry === "string") { | ||
imports.set(importEntry, importEntry); | ||
} else { | ||
imports.set(importEntry.as || importEntry.name, importEntry.name); | ||
} | ||
return this; | ||
} | ||
addDefault(path, as) { | ||
return this.add(path, { name: "default", as }); | ||
} | ||
getImportList(path) { | ||
if (!this.map.has(path)) | ||
return []; | ||
return Array.from(this.map.get(path)).map(([as, name]) => ({ | ||
as: as || name, | ||
name | ||
})); | ||
} | ||
toString() { | ||
let importStatements = ""; | ||
for (const [path, imports] of this.map) { | ||
if (!imports.size) | ||
continue; | ||
if (imports.size === 1) { | ||
const [[importName, maybeDefault]] = [...imports.entries()]; | ||
if (maybeDefault === "default") { | ||
importStatements += `import ${importName} from '${path}' | ||
`; | ||
continue; | ||
} | ||
} | ||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from '${path}' | ||
`; | ||
} | ||
return importStatements; | ||
} | ||
get size() { | ||
return this.map.size; | ||
} | ||
}; | ||
@@ -623,6 +674,6 @@ // src/core/treeNodeValue.ts | ||
// src/codegen/generateRouteRecords.ts | ||
function generateRouteRecord(node, options, importList, indent = 0) { | ||
function generateRouteRecord(node, options, importsMap, indent = 0) { | ||
if (node.value.path === "/" && indent === 0) { | ||
return `[ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 1)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 1)).join(",\n")} | ||
]`; | ||
@@ -641,3 +692,3 @@ } | ||
options.importMode, | ||
importList | ||
importsMap | ||
) : "/* no component */"} | ||
@@ -648,3 +699,3 @@ ${overrides.props != null ? indentStr + `props: ${overrides.props}, | ||
indentStr}${node.children.size > 0 ? `children: [ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 2)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 2)).join(",\n")} | ||
${indentStr}],` : "/* no children */"}${formatMeta(node, indentStr)} | ||
@@ -655,7 +706,8 @@ ${startIndent}}`; | ||
for (const [name, filePath] of node.value.components) { | ||
const pageDataImport = `_definePage_${name}_${importList.size}`; | ||
const pageDataImport = `_definePage_${name}_${importsMap.size}`; | ||
definePageDataList.push(pageDataImport); | ||
importList.set(pageDataImport, `${filePath}?definePage&vue`); | ||
importsMap.addDefault(`${filePath}?definePage&vue`, pageDataImport); | ||
} | ||
if (definePageDataList.length) { | ||
importsMap.add("unplugin-vue-router/runtime", "_mergeRouteRecord"); | ||
return ` _mergeRouteRecord( | ||
@@ -669,6 +721,6 @@ ${routeRecord}, | ||
} | ||
function generateRouteRecordComponent(node, indentStr, importMode, importList) { | ||
function generateRouteRecordComponent(node, indentStr, importMode, importsMap) { | ||
const files = Array.from(node.value.components); | ||
const isDefaultExport = files.length === 1 && files[0][0] === "default"; | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importList)},` : ( | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importsMap)},` : ( | ||
// files has at least one entry | ||
@@ -680,3 +732,3 @@ `components: { | ||
importMode, | ||
importList | ||
importsMap | ||
)}` | ||
@@ -687,3 +739,3 @@ ).join(",\n")} | ||
} | ||
function generatePageImport(filepath, importMode, importList) { | ||
function generatePageImport(filepath, importMode, importsMap) { | ||
const mode = typeof importMode === "function" ? importMode(filepath) : importMode; | ||
@@ -693,4 +745,4 @@ if (mode === "async") { | ||
} else { | ||
const importName = `_page_${importList.size}`; | ||
importList.set(importName, filepath); | ||
const importName = `_page_${importsMap.size}`; | ||
importsMap.addDefault(filepath, importName); | ||
return importName; | ||
@@ -856,3 +908,3 @@ } | ||
_DefineLoaderOptions, | ||
} from 'unplugin-vue-router' | ||
} from 'unplugin-vue-router/types' | ||
@@ -917,3 +969,3 @@ declare module '${routesModule}' { | ||
export const RouterLink: RouterLinkTyped<RouteNamedMap> | ||
// Experimental Data Fetching | ||
@@ -1261,2 +1313,11 @@ | ||
/** | ||
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method | ||
* **only returns direct children**. | ||
*/ | ||
get children() { | ||
return [...this.node.children.values()].map( | ||
(node) => new EditableTreeNode(node) | ||
); | ||
} | ||
/** | ||
* DFS traversal of the tree. | ||
@@ -1407,17 +1468,12 @@ * @example | ||
function generateRoutes() { | ||
const importList = /* @__PURE__ */ new Map(); | ||
const importsMap = new ImportsMap(); | ||
const routesExport = `export const routes = ${generateRouteRecord( | ||
routeTree, | ||
options, | ||
importList | ||
importsMap | ||
)}`; | ||
let imports = ""; | ||
if (true) { | ||
imports += `import { _HasDataLoaderMeta, _mergeRouteRecord } from 'unplugin-vue-router/runtime' | ||
`; | ||
if (options.dataFetching) { | ||
importsMap.add("unplugin-vue-router/runtime", "_HasDataLoaderMeta"); | ||
} | ||
for (const [name, path] of importList) { | ||
imports += `import ${name} from '${path}' | ||
`; | ||
} | ||
let imports = `${importsMap}`; | ||
if (imports) { | ||
@@ -1424,0 +1480,0 @@ imports += "\n"; |
import { Router, RouteLocationNormalized, RouteRecordRaw } from 'vue-router'; | ||
import { a as DataLoader } from './defineLoader-bde635fd.js'; | ||
export { D as DefineLoaderOptions, d as _defineLoader, s as _stopDataFetchingScope } from './defineLoader-bde635fd.js'; | ||
import { A as Awaitable } from './options-3030b9f1.js'; | ||
import { A as Awaitable } from './options-7332b95e.js'; | ||
import 'vue'; | ||
@@ -6,0 +6,0 @@ |
import * as vite from 'vite'; | ||
import { O as Options } from './options-3030b9f1.js'; | ||
import { O as Options } from './options-7332b95e.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
104
dist/vite.js
@@ -193,2 +193,53 @@ "use strict"; | ||
} | ||
var ImportsMap = class { | ||
constructor() { | ||
// path -> import as -> import name | ||
// e.g map['vue-router']['myUseRouter'] = 'useRouter' -> import { useRouter as myUseRouter } from 'vue-router' | ||
this.map = /* @__PURE__ */ new Map(); | ||
} | ||
add(path, importEntry) { | ||
if (!this.map.has(path)) { | ||
this.map.set(path, /* @__PURE__ */ new Map()); | ||
} | ||
const imports = this.map.get(path); | ||
if (typeof importEntry === "string") { | ||
imports.set(importEntry, importEntry); | ||
} else { | ||
imports.set(importEntry.as || importEntry.name, importEntry.name); | ||
} | ||
return this; | ||
} | ||
addDefault(path, as) { | ||
return this.add(path, { name: "default", as }); | ||
} | ||
getImportList(path) { | ||
if (!this.map.has(path)) | ||
return []; | ||
return Array.from(this.map.get(path)).map(([as, name]) => ({ | ||
as: as || name, | ||
name | ||
})); | ||
} | ||
toString() { | ||
let importStatements = ""; | ||
for (const [path, imports] of this.map) { | ||
if (!imports.size) | ||
continue; | ||
if (imports.size === 1) { | ||
const [[importName, maybeDefault]] = [...imports.entries()]; | ||
if (maybeDefault === "default") { | ||
importStatements += `import ${importName} from '${path}' | ||
`; | ||
continue; | ||
} | ||
} | ||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from '${path}' | ||
`; | ||
} | ||
return importStatements; | ||
} | ||
get size() { | ||
return this.map.size; | ||
} | ||
}; | ||
@@ -623,6 +674,6 @@ // src/core/treeNodeValue.ts | ||
// src/codegen/generateRouteRecords.ts | ||
function generateRouteRecord(node, options, importList, indent = 0) { | ||
function generateRouteRecord(node, options, importsMap, indent = 0) { | ||
if (node.value.path === "/" && indent === 0) { | ||
return `[ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 1)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 1)).join(",\n")} | ||
]`; | ||
@@ -641,3 +692,3 @@ } | ||
options.importMode, | ||
importList | ||
importsMap | ||
) : "/* no component */"} | ||
@@ -648,3 +699,3 @@ ${overrides.props != null ? indentStr + `props: ${overrides.props}, | ||
indentStr}${node.children.size > 0 ? `children: [ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 2)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 2)).join(",\n")} | ||
${indentStr}],` : "/* no children */"}${formatMeta(node, indentStr)} | ||
@@ -655,7 +706,8 @@ ${startIndent}}`; | ||
for (const [name, filePath] of node.value.components) { | ||
const pageDataImport = `_definePage_${name}_${importList.size}`; | ||
const pageDataImport = `_definePage_${name}_${importsMap.size}`; | ||
definePageDataList.push(pageDataImport); | ||
importList.set(pageDataImport, `${filePath}?definePage&vue`); | ||
importsMap.addDefault(`${filePath}?definePage&vue`, pageDataImport); | ||
} | ||
if (definePageDataList.length) { | ||
importsMap.add("unplugin-vue-router/runtime", "_mergeRouteRecord"); | ||
return ` _mergeRouteRecord( | ||
@@ -669,6 +721,6 @@ ${routeRecord}, | ||
} | ||
function generateRouteRecordComponent(node, indentStr, importMode, importList) { | ||
function generateRouteRecordComponent(node, indentStr, importMode, importsMap) { | ||
const files = Array.from(node.value.components); | ||
const isDefaultExport = files.length === 1 && files[0][0] === "default"; | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importList)},` : ( | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importsMap)},` : ( | ||
// files has at least one entry | ||
@@ -680,3 +732,3 @@ `components: { | ||
importMode, | ||
importList | ||
importsMap | ||
)}` | ||
@@ -687,3 +739,3 @@ ).join(",\n")} | ||
} | ||
function generatePageImport(filepath, importMode, importList) { | ||
function generatePageImport(filepath, importMode, importsMap) { | ||
const mode = typeof importMode === "function" ? importMode(filepath) : importMode; | ||
@@ -693,4 +745,4 @@ if (mode === "async") { | ||
} else { | ||
const importName = `_page_${importList.size}`; | ||
importList.set(importName, filepath); | ||
const importName = `_page_${importsMap.size}`; | ||
importsMap.addDefault(filepath, importName); | ||
return importName; | ||
@@ -856,3 +908,3 @@ } | ||
_DefineLoaderOptions, | ||
} from 'unplugin-vue-router' | ||
} from 'unplugin-vue-router/types' | ||
@@ -917,3 +969,3 @@ declare module '${routesModule}' { | ||
export const RouterLink: RouterLinkTyped<RouteNamedMap> | ||
// Experimental Data Fetching | ||
@@ -1261,2 +1313,11 @@ | ||
/** | ||
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method | ||
* **only returns direct children**. | ||
*/ | ||
get children() { | ||
return [...this.node.children.values()].map( | ||
(node) => new EditableTreeNode(node) | ||
); | ||
} | ||
/** | ||
* DFS traversal of the tree. | ||
@@ -1407,17 +1468,12 @@ * @example | ||
function generateRoutes() { | ||
const importList = /* @__PURE__ */ new Map(); | ||
const importsMap = new ImportsMap(); | ||
const routesExport = `export const routes = ${generateRouteRecord( | ||
routeTree, | ||
options, | ||
importList | ||
importsMap | ||
)}`; | ||
let imports = ""; | ||
if (true) { | ||
imports += `import { _HasDataLoaderMeta, _mergeRouteRecord } from 'unplugin-vue-router/runtime' | ||
`; | ||
if (options.dataFetching) { | ||
importsMap.add("unplugin-vue-router/runtime", "_HasDataLoaderMeta"); | ||
} | ||
for (const [name, path] of importList) { | ||
imports += `import ${name} from '${path}' | ||
`; | ||
} | ||
let imports = `${importsMap}`; | ||
if (imports) { | ||
@@ -1424,0 +1480,0 @@ imports += "\n"; |
import * as webpack from 'webpack'; | ||
import { O as Options } from './options-3030b9f1.js'; | ||
import { O as Options } from './options-7332b95e.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
@@ -193,2 +193,53 @@ "use strict"; | ||
} | ||
var ImportsMap = class { | ||
constructor() { | ||
// path -> import as -> import name | ||
// e.g map['vue-router']['myUseRouter'] = 'useRouter' -> import { useRouter as myUseRouter } from 'vue-router' | ||
this.map = /* @__PURE__ */ new Map(); | ||
} | ||
add(path, importEntry) { | ||
if (!this.map.has(path)) { | ||
this.map.set(path, /* @__PURE__ */ new Map()); | ||
} | ||
const imports = this.map.get(path); | ||
if (typeof importEntry === "string") { | ||
imports.set(importEntry, importEntry); | ||
} else { | ||
imports.set(importEntry.as || importEntry.name, importEntry.name); | ||
} | ||
return this; | ||
} | ||
addDefault(path, as) { | ||
return this.add(path, { name: "default", as }); | ||
} | ||
getImportList(path) { | ||
if (!this.map.has(path)) | ||
return []; | ||
return Array.from(this.map.get(path)).map(([as, name]) => ({ | ||
as: as || name, | ||
name | ||
})); | ||
} | ||
toString() { | ||
let importStatements = ""; | ||
for (const [path, imports] of this.map) { | ||
if (!imports.size) | ||
continue; | ||
if (imports.size === 1) { | ||
const [[importName, maybeDefault]] = [...imports.entries()]; | ||
if (maybeDefault === "default") { | ||
importStatements += `import ${importName} from '${path}' | ||
`; | ||
continue; | ||
} | ||
} | ||
importStatements += `import { ${Array.from(imports).map(([as, name]) => as === name ? name : `${name} as ${as}`).join(", ")} } from '${path}' | ||
`; | ||
} | ||
return importStatements; | ||
} | ||
get size() { | ||
return this.map.size; | ||
} | ||
}; | ||
@@ -623,6 +674,6 @@ // src/core/treeNodeValue.ts | ||
// src/codegen/generateRouteRecords.ts | ||
function generateRouteRecord(node, options, importList, indent = 0) { | ||
function generateRouteRecord(node, options, importsMap, indent = 0) { | ||
if (node.value.path === "/" && indent === 0) { | ||
return `[ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 1)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 1)).join(",\n")} | ||
]`; | ||
@@ -641,3 +692,3 @@ } | ||
options.importMode, | ||
importList | ||
importsMap | ||
) : "/* no component */"} | ||
@@ -648,3 +699,3 @@ ${overrides.props != null ? indentStr + `props: ${overrides.props}, | ||
indentStr}${node.children.size > 0 ? `children: [ | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importList, indent + 2)).join(",\n")} | ||
${node.getSortedChildren().map((child) => generateRouteRecord(child, options, importsMap, indent + 2)).join(",\n")} | ||
${indentStr}],` : "/* no children */"}${formatMeta(node, indentStr)} | ||
@@ -655,7 +706,8 @@ ${startIndent}}`; | ||
for (const [name, filePath] of node.value.components) { | ||
const pageDataImport = `_definePage_${name}_${importList.size}`; | ||
const pageDataImport = `_definePage_${name}_${importsMap.size}`; | ||
definePageDataList.push(pageDataImport); | ||
importList.set(pageDataImport, `${filePath}?definePage&vue`); | ||
importsMap.addDefault(`${filePath}?definePage&vue`, pageDataImport); | ||
} | ||
if (definePageDataList.length) { | ||
importsMap.add("unplugin-vue-router/runtime", "_mergeRouteRecord"); | ||
return ` _mergeRouteRecord( | ||
@@ -669,6 +721,6 @@ ${routeRecord}, | ||
} | ||
function generateRouteRecordComponent(node, indentStr, importMode, importList) { | ||
function generateRouteRecordComponent(node, indentStr, importMode, importsMap) { | ||
const files = Array.from(node.value.components); | ||
const isDefaultExport = files.length === 1 && files[0][0] === "default"; | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importList)},` : ( | ||
return isDefaultExport ? `component: ${generatePageImport(files[0][1], importMode, importsMap)},` : ( | ||
// files has at least one entry | ||
@@ -680,3 +732,3 @@ `components: { | ||
importMode, | ||
importList | ||
importsMap | ||
)}` | ||
@@ -687,3 +739,3 @@ ).join(",\n")} | ||
} | ||
function generatePageImport(filepath, importMode, importList) { | ||
function generatePageImport(filepath, importMode, importsMap) { | ||
const mode = typeof importMode === "function" ? importMode(filepath) : importMode; | ||
@@ -693,4 +745,4 @@ if (mode === "async") { | ||
} else { | ||
const importName = `_page_${importList.size}`; | ||
importList.set(importName, filepath); | ||
const importName = `_page_${importsMap.size}`; | ||
importsMap.addDefault(filepath, importName); | ||
return importName; | ||
@@ -856,3 +908,3 @@ } | ||
_DefineLoaderOptions, | ||
} from 'unplugin-vue-router' | ||
} from 'unplugin-vue-router/types' | ||
@@ -917,3 +969,3 @@ declare module '${routesModule}' { | ||
export const RouterLink: RouterLinkTyped<RouteNamedMap> | ||
// Experimental Data Fetching | ||
@@ -1261,2 +1313,11 @@ | ||
/** | ||
* Computes an array of EditableTreeNode from the current node. Differently from iterating over the tree, this method | ||
* **only returns direct children**. | ||
*/ | ||
get children() { | ||
return [...this.node.children.values()].map( | ||
(node) => new EditableTreeNode(node) | ||
); | ||
} | ||
/** | ||
* DFS traversal of the tree. | ||
@@ -1407,17 +1468,12 @@ * @example | ||
function generateRoutes() { | ||
const importList = /* @__PURE__ */ new Map(); | ||
const importsMap = new ImportsMap(); | ||
const routesExport = `export const routes = ${generateRouteRecord( | ||
routeTree, | ||
options, | ||
importList | ||
importsMap | ||
)}`; | ||
let imports = ""; | ||
if (true) { | ||
imports += `import { _HasDataLoaderMeta, _mergeRouteRecord } from 'unplugin-vue-router/runtime' | ||
`; | ||
if (options.dataFetching) { | ||
importsMap.add("unplugin-vue-router/runtime", "_HasDataLoaderMeta"); | ||
} | ||
for (const [name, path] of importList) { | ||
imports += `import ${name} from '${path}' | ||
`; | ||
} | ||
let imports = `${importsMap}`; | ||
if (imports) { | ||
@@ -1424,0 +1480,0 @@ imports += "\n"; |
{ | ||
"name": "unplugin-vue-router", | ||
"version": "0.5.4", | ||
"packageManager": "pnpm@7.28.0", | ||
"version": "0.5.5", | ||
"packageManager": "pnpm@8.2.0", | ||
"description": "File based typed routing for Vue Router", | ||
@@ -59,2 +59,6 @@ "keywords": [ | ||
}, | ||
"./types": { | ||
"require": "./dist/types.js", | ||
"import": "./dist/types.mjs" | ||
}, | ||
"./*": "./*" | ||
@@ -80,6 +84,6 @@ }, | ||
"dependencies": { | ||
"@babel/types": "^7.21.2", | ||
"@babel/types": "^7.21.4", | ||
"@rollup/pluginutils": "^5.0.2", | ||
"@vue-macros/common": "^1.1.0", | ||
"ast-walker-scope": "^0.4.0", | ||
"@vue-macros/common": "^1.2.0", | ||
"ast-walker-scope": "^0.4.1", | ||
"chokidar": "^3.5.3", | ||
@@ -89,6 +93,6 @@ "fast-glob": "^3.2.12", | ||
"local-pkg": "^0.4.3", | ||
"mlly": "^1.1.1", | ||
"mlly": "^1.2.0", | ||
"pathe": "^1.1.0", | ||
"scule": "^1.0.0", | ||
"unplugin": "^1.1.0", | ||
"unplugin": "^1.3.1", | ||
"yaml": "^2.2.1" | ||
@@ -111,21 +115,21 @@ }, | ||
"esno": "^0.16.3", | ||
"execa": "^7.0.0", | ||
"lint-staged": "^13.1.2", | ||
"execa": "^7.1.1", | ||
"lint-staged": "^13.2.1", | ||
"minimist": "^1.2.8", | ||
"nodemon": "^2.0.20", | ||
"nodemon": "^2.0.22", | ||
"p-series": "^3.0.0", | ||
"prettier": "^2.8.4", | ||
"rimraf": "^4.1.2", | ||
"rollup": "^3.17.3", | ||
"semver": "^7.3.8", | ||
"prettier": "^2.8.7", | ||
"rimraf": "^5.0.0", | ||
"rollup": "^3.20.4", | ||
"semver": "^7.4.0", | ||
"ts-expect": "^1.3.0", | ||
"tsup": "^6.6.3", | ||
"typescript": "^4.9.5", | ||
"unplugin-auto-import": "^0.15.0", | ||
"vite": "^4.1.4", | ||
"vite-plugin-vue-markdown": "^0.22.4", | ||
"vitest": "^0.29.1", | ||
"tsup": "^6.7.0", | ||
"typescript": "^5.0.4", | ||
"unplugin-auto-import": "^0.15.3", | ||
"vite": "^4.2.1", | ||
"vite-plugin-vue-markdown": "^0.22.5", | ||
"vitest": "^0.30.1", | ||
"vue": "^3.2.47", | ||
"vue-router": "^4.1.6", | ||
"webpack": "^5.75.0", | ||
"webpack": "^5.79.0", | ||
"yorkie": "^2.0.0" | ||
@@ -132,0 +136,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
45
22
1
417194
11663
Updated@babel/types@^7.21.4
Updated@vue-macros/common@^1.2.0
Updatedast-walker-scope@^0.4.1
Updatedmlly@^1.2.0
Updatedunplugin@^1.3.1