Files
sapper/runtime/src/app/prefetchRoutes/index.ts
Rich Harris ca034d0857 Support Svelte 3
fixes #546, #551, #552, #554
2019-02-03 14:29:47 -05:00

13 lines
485 B
TypeScript

import { components, routes } from '@sapper/internal/manifest-client';
import { load_component } from '../app';
export default function prefetchRoutes(pathnames: string[]) {
return routes
.filter(pathnames
? route => pathnames.some(pathname => route.pattern.test(pathname))
: () => true
)
.reduce((promise: Promise<any>, route) => promise.then(() => {
return Promise.all(route.parts.map(part => part && load_component(components[part.i])));
}), Promise.resolve());
}