Reputation: 3
Many thanks about this piece of code.
export const page;
router('/access', () =>
import('./views/access.svelte').then(
module => page.set({ component: module.default })
)
);
Upvotes: 0
Views: 120
Reputation: 1260
import router from 'page'
most likely refers to page.js, a JavaScript router (that doesn't have any Svelte dependency)module.default
refers to the default export of the file that is passed as the first argument to the import()
function. This file would be './views/dashboard.svelte'
in
router('/dashboard', () =>
import('./views/dashboard.svelte').then(
module => page.set({ component: module.default })
)
);
As all the imported files are Svelte components, the default export would be the component itself.import(/*component path here*/, /*more code here*/)
requires any props.Also, note that, although initially the page store is initialized with an object that has both, a component
and props
field, the page store's value is subsequently overwritten with an object that just has the component
field (at all the calls to page.set()
).
Upvotes: 2