Skip to content
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: separate framework code from app code #8957

Merged
merged 21 commits into from
Feb 19, 2023
Merged

fix: separate framework code from app code #8957

merged 21 commits into from
Feb 19, 2023

Conversation

Rich-Harris
Copy link
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:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

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
Member Author

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

This reverts commit a08b5d8.
@dummdidumm
Copy link
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
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
5 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
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