diff --git a/src/runtime/index.ts b/src/runtime/index.ts index d0fe37d..445ae67 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -271,7 +271,12 @@ export function preloadRoutes(pathnames: string[]) { return routes .filter(route => { - return !pathnames || pathnames.some(pathname => route.pattern.test(pathname)); + if (!pathnames) return true; + return pathnames.some(pathname => { + return route.error + ? route.error === pathname + : route.pattern.test(pathname) + }); }) .reduce((promise: Promise, route) => { return promise.then(route.load); diff --git a/src/runtime/interfaces.ts b/src/runtime/interfaces.ts index e20349e..b2f9574 100644 --- a/src/runtime/interfaces.ts +++ b/src/runtime/interfaces.ts @@ -13,8 +13,9 @@ export interface Component { export type Route = { pattern: RegExp; - params: (match: RegExpExecArray) => Record; load: () => Promise<{ default: ComponentConstructor }>; + error?: string; + params?: (match: RegExpExecArray) => Record; ignore?: boolean; };