error on incorrect init args

This commit is contained in:
Rich Harris
2018-05-04 23:06:10 -04:00
parent 8ee5346900
commit 3becc1cbe2
2 changed files with 8 additions and 0 deletions

View File

@@ -54,6 +54,10 @@ export default function middleware({ App, routes, store }: {
routes: RouteObject[],
store: (req: Req) => Store
}) {
if (!App) {
throw new Error(`As of 0.12, you must supply an App component to Sapper — see https://sapper.svelte.technology/guide#0-11-to-0-12 for more information`);
}
const output = locations.dest();
const client_info = JSON.parse(fs.readFileSync(path.join(output, 'client_info.json'), 'utf-8'));

View File

@@ -251,6 +251,10 @@ function trigger_prefetch(event: MouseEvent | TouchEvent) {
let inited: boolean;
export function init(opts: { App: ComponentConstructor, target: Node, routes: Route[], store?: (data: any) => Store }) {
if (opts instanceof HTMLElement) {
throw new Error(`The signature of init(...) has changed — see https://sapper.svelte.technology/guide#0-11-to-0-12 for more information`);
}
App = opts.App;
target = opts.target;
routes = opts.routes.filter(r => !r.error);