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