-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[feat] SSR never option #2529
[feat] SSR never option #2529
Conversation
🦋 Changeset detectedLatest commit: be01755 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
1e6185e
to
64947d0
Compare
…to ssr-never-option
Hey @benmccann, do you how I can create a new test app? |
Do you think the docs are clear enough now? |
Shows the name of the file that was attempted to be loaded while ssr was set to "never"
Is there any known workaround while this PR bakes? As far as I can tell, this issue completely blocks final building our SPA that uses web workers extensively. |
Here are the current workarounds |
Thanks for the PR. I'm -1 on this — this has been discussed in the maintainer's chatroom but not here, I think, so let me explain: In general, we want to encourage the use of SSR as widely as possible. We therefore don't want people to solve the 'I can't SSR this particular page' problem by disabling SSR for the entire app. While there are situations where disabling SSR app-wide is the correct thing to do, in the many cases where that's not the case, the existence of this option would encourage bad practices. I think something like the following is preferable: export function handle({ request, resolve }) {
return resolve(request, { ssr: false });
} That way it can easily be scoped to specific parts of the app, for example, or even conditionally enabled for some UAs. It requires some discussion (not sure if adding options to |
I might suggest |
This comment has been minimized.
This comment has been minimized.
Rich's suggestion would allow you to completely disable SSR if you'd like. It'd be more powerful though - it would let you decide whether to disable on a per-page / per-request basis. If you really have a need to always set it to |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
That's a great solution, but it doesn't solve one problem: the final app bundle. All sveltekit pages and their dependencies are bundled into |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@JeanJPNM that's a great point. That's because Kit sets kit/packages/kit/src/core/build/index.js Line 445 in d15e369
I'm not really sure that we need to though, so perhaps we can change it |
styles | ||
}; | ||
}); | ||
if (allow_ssr) { |
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.
is there any harm in having metadata_lookup
populated even if it's not used? I wonder if it might be simpler to just leave the code as is and not add an extra condition, but want to make sure I'm not missing anything
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.
Not really, I just thought that it would be better to not populate metadata_lookup
when it isn't going to be used.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
With that problem out of the way, we can implement @Rich-Harris's solution without any drawbacks (though I think that option should be renamed to something like |
I much prefer |
Closing in favor of #2804. |
This pull request aims to close #1650 by adding a
never
value to thessr
option, preventing svelte kit from importing the files on the server altogether.Other alternatives: add
spa
option to config.Todo list: