From 65e4a3319bb5c164314f9603fa2241495eba58be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=B5hjakivi?= Date: Thu, 3 Aug 2023 12:45:25 +0300 Subject: [PATCH] introduce lazy loading for routes (-25% in chunk sizes) --- src/routes.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/routes.ts b/src/routes.ts index a7b145a..9dc669b 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -1,9 +1,12 @@ -import Home from "./components/Home.svelte"; -import Handheld from "./components/Handheld.svelte"; +import wrap from "svelte-spa-router/wrap"; const routes = { - '/': Home, - '/handheld': Handheld, + '/': wrap({ + asyncComponent: () => import('./components/Home.svelte') + }), + '/handheld': wrap({ + asyncComponent: () => import('./components/Handheld.svelte') + }), } export {routes} \ No newline at end of file