Skip to content

fix: separate framework code from app code - #8957

Merged
Rich-Harris merged 21 commits into
masterfrom
gh-8464
Feb 19, 2023
Merged

Rich-Harris merged 21 commits into
masterfrom
gh-8464

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

This is an alternative to #8803, and closes #8464 albeit via a somewhat larger change.

Essentially this splits out the app code from the framework code, and passes app information to the framework via the start(...) call. This gives us an opportunity to set environment variables before any app code runs, but it also has a nice side-effect — the framework code now resides in its own chunk, with a stable hash. This will make cache hits more frequent, since the start.js chunk will only be invalidated when there's a new framework version, not when there's a new app version.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@Rich-Harris

Copy link
Copy Markdown
Member Author

Flummoxed by the test failure. Happens reliably, but not locally.

This reverts commit a08b5d8.
@dummdidumm

Copy link
Copy Markdown
Member

I added some console.logs to see where the failure might be. Seems like app is imported and loaded properly, and it hangs somewhere inside _hydrate of client.js

This reverts commit ec618f5.
@Rich-Harris Rich-Harris mentioned this pull request Feb 18, 2023
4 of 5 tasks
@Rich-Harris
Rich-Harris merged commit 46eec82 into master Feb 19, 2023
@Rich-Harris
Rich-Harris deleted the gh-8464 branch February 19, 2023 01:56
@github-actions github-actions Bot mentioned this pull request Feb 19, 2023
@benmccann benmccann mentioned this pull request Feb 21, 2023
2 of 5 tasks
@gtm-nayan gtm-nayan mentioned this pull request Sep 21, 2024
4 of 6 tasks
dummdidumm pushed a commit that referenced this pull request Oct 7, 2024
In #8957 one of the desired outcomes was that the framework code would have its own chunk with a stable hash for better caching, but that didn't really happen because the client imports something that references version, through __sveltekit/environment for created_updated_store and version hash through __sveltekit/path, which meant that when the developer changes their app code and increments/changes the version it'd also change the above mentioned modules and subsequently most chunks with the framework code

In this PR the version is injected in generateBundle once the chunk hashes have already been calculated so that just changing the version doesn't affect the hashes for chunks without any actual code changes

fixes #12260

This branch was successfully deployed

2 active deployments
Preview – kit-svelte-dev — 387f009b Deployed Feb 17, 2023 by vercel[bot]
Preview – kit — 387f009b Deployed Feb 17, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$env/dynamic/public isn't available in hooks.client.js in prod

5 participants