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: correctly resolve $app/state (alternative) #13192

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

dummdidumm
Copy link
Member

Alternative to #13181, fixes #13179

Uses the same approach as the other virtual modules to differentiate between client and server

Note that I haven't tested this out with an actual Vite 5 project yet (if someone could that would be great; I probably won't have much time to do so)


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:.

fixes #13179

Uses the same approach as the other virtual modules to differentiate between client and server
Copy link

changeset-bot bot commented Dec 18, 2024

🦋 Changeset detected

Latest commit: ebd0d32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dominikg
Copy link
Member

do we want to keep the separate client and server files and rely on them being side effect free and the unused import treeshaken or consolidate all code into the index file and branch inside this one file?

looking at https://github.com/sveltejs/kit/blob/main/packages/kit/src/runtime/app/stores.js maybe app/state.js instead of a subdirctory with 3 files would follow that pattern more closely?

@dummdidumm
Copy link
Member Author

I kept it like this because it made code easier to reason about - TBH we should maybe go the other way around if we want to consolidate. And also, if we require Vite 6 in SvelteKit 3, we could switch back to the package.json approach, as that seems to work there.

@eltigerchino
Copy link
Member

eltigerchino commented Dec 19, 2024

It works 👍🏼 Vite 5 example with this PR

@Rich-Harris Rich-Harris merged commit 5d30191 into main Dec 19, 2024
14 checks passed
@Rich-Harris Rich-Harris deleted the app-state-client-server-fix branch December 19, 2024 04:34
@github-actions github-actions bot mentioned this pull request Dec 18, 2024
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.

SvelteKit 2.12.1 with @sveltejs/vite-plugin-svelte 4.0.3 return weird server-side results
4 participants