mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-21 06:45:00 +00:00
preload errors
This commit is contained in:
@@ -271,7 +271,12 @@ export function preloadRoutes(pathnames: string[]) {
|
|||||||
|
|
||||||
return routes
|
return routes
|
||||||
.filter(route => {
|
.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<any>, route) => {
|
.reduce((promise: Promise<any>, route) => {
|
||||||
return promise.then(route.load);
|
return promise.then(route.load);
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ export interface Component {
|
|||||||
|
|
||||||
export type Route = {
|
export type Route = {
|
||||||
pattern: RegExp;
|
pattern: RegExp;
|
||||||
params: (match: RegExpExecArray) => Record<string, string>;
|
|
||||||
load: () => Promise<{ default: ComponentConstructor }>;
|
load: () => Promise<{ default: ComponentConstructor }>;
|
||||||
|
error?: string;
|
||||||
|
params?: (match: RegExpExecArray) => Record<string, string>;
|
||||||
ignore?: boolean;
|
ignore?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user