-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] Import fallback components when they are actually required #2160
[fix] Import fallback components when they are actually required #2160
Conversation
|
I had earlier sent a PR(#1356) doing the same, but was not merged because of the reasons mentioned in the comments given by Rich. For @benmccann |
Yep, the behaviour is intentional. I've opened a PR that would hopefully prevent this confusion in future: #2183 |
Thanks for the PR. I'm going to close this for the reason noted above — this is intended behaviour (loading the root layout and error components in the background regardless of whether we expect to need them for the initial view). Not set in stone, but we'd need to discuss alternatives in an issue and figure out what the ideal behaviour would be, if it's not the status quo |
Fixes #2154 and fixes #2130
The root cause for the above two issues is in the manifest file which exports the routes and the fallback. The fallback components (
__layout.svelte
anderror.svelte
) are always imported because of the way they are exported from the manifest. Always importing the components causes module-context code to run even when the layout is reset.Proposed Changes
This PR changes the way the fallback components are exported and utilized in the Renderer. The fallback array now is of type
[() => CSRComponent, () => CSRComponent]
which was previously[CSRComponent, CSRComponent]
. And the function to import these components are called only when required.Now the generated manifest file would look something like below.
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0