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

Sveltekit: Ensure SSR is disabled #20804

Merged
merged 1 commit into from
Jan 27, 2023
Merged

Sveltekit: Ensure SSR is disabled #20804

merged 1 commit into from
Jan 27, 2023

Conversation

IanVS
Copy link
Member

@IanVS IanVS commented Jan 27, 2023

Issue: #

Sveltekit recently made a change which stopped setting build.ssr to false, and it is instead now true because of https://github.com/sveltejs/kit/blob/ead8fa8f8b7dd7fb73bdd1a6a2c3c2172162a25d/packages/kit/src/exports/vite/index.js#L254. This causes Vite to throw an error:

info => Manager built (78 ms)

vite v4.0.4 building SSR bundle for production...

ERR! Error: rollupOptions.input should not be an html file when building for SSR. Please specify a dedicated SSR entry.
ERR!     at doBuild (file:///Users/jeppe/dev/chromatic/sk-sb-70fail/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:44378:15)
ERR!     at async Module.build (file:///Users/jeppe/dev/chromatic/sk-sb-70fail/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:44347:16)
ERR!     at build (/Users/jeppe/dev/chromatic/sk-sb-70fail/node_modules/@storybook/builder-vite/dist/index.js:162:8154)

What I did

We can't set build.ssr to false in builder-vite, because then sveltekit will overwrite it. So we need to use a plugin that's loaded after the sveltekit plugin, which resets build.ssr to false, which is what I've done here.

The other option would be for sveltekit to move this config into their vite-plugin-sveltekit-compile plugin, but there may be internal pushback against that from the sveltekit team.

How to test

If the sveltekit sandbox builds, we're good to go.

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@JReinhold JReinhold added the ci:daily Run the CI jobs that normally run in the daily job. label Jan 27, 2023
@JReinhold JReinhold self-assigned this Jan 27, 2023
Copy link
Contributor

@JReinhold JReinhold left a comment

Choose a reason for hiding this comment

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

This is good, thanks for the swift response!

I'm wondering if we should do this globally in the Vite builder instead of only here in SvelteKit, seems more safe that we force SSR false in all cases.

Either way, let's merge this in to unblock CI.

@JReinhold JReinhold merged commit 62ebc82 into next Jan 27, 2023
@JReinhold JReinhold deleted the fix-sveltekit branch January 27, 2023 08:24
@IanVS
Copy link
Member Author

IanVS commented Jan 27, 2023

I see this as a bit of a hack, and I'd prefer not to have to do it in the core vite builder unless we have to. Though maybe we'll find that other users hit this kind of issue and we might have to reconsider.

We already throw away the user's build settings, so this kind of thing can only happen in plugins that change the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ci:daily Run the CI jobs that normally run in the daily job. sveltekit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants