0

Many thanks about this piece of code.

export const page;

router('/access', () =>
    import('./views/access.svelte').then(
    module => page.set({ component: module.default })
    )
);

1 Answer 1

2
  • page in 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.
  • Why props are defined as empty I can't tell. But possibly, none of the components specified in 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()).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.