-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
|
export function beforeUpdate() {} | ||
export function mount() { | ||
throw new Error('mount(...) is not available on the server'); | ||
} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
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.