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

chore: tidy up server exports #10972

Merged
merged 5 commits into from
Mar 28, 2024
Merged

chore: tidy up server exports #10972

merged 5 commits into from
Mar 28, 2024

Conversation

Rich-Harris
Copy link
Member

Rather than re-exporting client code, the server entry file should implement things that can be exported from svelte. This means duplicating some context-related code, but it means we can be much more efficient about what goes into server bundles, and what objects get created during SSR.

Copy link

changeset-bot bot commented Mar 28, 2024

⚠️ No Changeset found

Latest commit: 4c0b723

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

export function beforeUpdate() {}
export function mount() {
throw new Error('mount(...) is not available on the server');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously it was possible to use client APIs and its runtime in a server context, assuming the Dom APIs are shimmed. This most likely happens when using test runners. Are we ok with this use case no longer being possible? (The test runner case would need adjustments for export conditions, if that doesn't happen already automatically)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach will lead to less confusion in general — if people expect mount to work without any configuration changes to their test runner or whatever, then they will probably expect things like unstate to work (which it won't), and things are very likely to break in future. This way, we force people to do things the right way from the get-go

@Rich-Harris Rich-Harris merged commit f303d82 into main Mar 28, 2024
8 checks passed
@Rich-Harris Rich-Harris deleted the tidy-up-server-exports branch March 28, 2024 21:21
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.

2 participants