chore(deps): update @sveltejs/vite-plugin-svelte to v7#16549
Conversation
🦋 Changeset detectedLatest commit: 3c0cd6b The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
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 |
73bb876 to
94e8603
Compare
| // vite-plugin-svelte's classification (pinned to v7.1.2): | ||
| // https://github.com/sveltejs/vite-plugin-svelte/blob/471f82216d4459a90d20f21c76b84aaf20c27e6e/packages/vite-plugin-svelte/src/utils/options.js#L478-L513 |
There was a problem hiding this comment.
The explanation makes sense, but adding a link isn't future proof because things can change. Do you need a TODO or FIXME instead?
There was a problem hiding this comment.
adding a link isn't future proof because things can change
I switched it from a commit SHA to a version tag permalink. Hope the pinned version is explicit and easy to diff if upstream changes later. See commit 3c0cd6b
Do you need a TODO or FIXME instead?
To clarify: do you mean this workaround is temporary and the real fix belongs upstream in vite-plugin-svelte?
If so, I'm not familiar enough with vite-plugin-svelte to tell.
There was a problem hiding this comment.
If so, I'm not familiar enough with vite-plugin-svelte to tell.
Neither do I 😆
| // The vite-plugin-svelte code that pre-bundles it (pinned to v7.1.2): | ||
| // https://github.com/sveltejs/vite-plugin-svelte/blob/471f82216d4459a90d20f21c76b84aaf20c27e6e/packages/vite-plugin-svelte/src/plugins/setup-optimizer.js#L51-L52 |
Bumps the
@sveltejs/vite-plugin-sveltedependency of@astrojs/sveltefrom v6 to v7.Why this is more than a version bump
vite-plugin-sveltev7's optimizer now pre-bundles Svelte's SSR runtime (svelte/server,svelte/internal/server) intooptimizeDepsfor server environments (packages/vite-plugin-svelte/src/plugins/setup-optimizer.js). Astro's renderer entrypoint (@astrojs/svelte/server.js) is resolved as anoExternaldependency, so it keeps the raw transformed copy of that runtime while the user's compiled components get the pre-bundled copy. Two copies means twossr_contextmodule states — Svelte's dev-onlypush_elementthen reads anullcontext and dev SSR crashes.It is dev-only (
optimizeDepsandpush_elementare both dev-only), so the build kept passing and the regression was easy to miss.Fix
A small
enforce: 'pre'Vite plugin excludessveltefromoptimizeDepsfor server environments (packages/integrations/svelte/src/index.ts), sovite-plugin-svelteskips the pre-bundle and the renderer and the components share one transformed copy.The integration's old
optimizeDepsoverrides are dropped as redundant:optimizeDeps.includeof the Svelte SSR runtime —vite-plugin-sveltev7 does this itself (and it is what causes the bug above).optimize-esbuild-plugins.ts—vite-plugin-sveltev7 registers its own.svelteoptimizer plugins (packages/vite-plugin-svelte/src/plugins/setup-optimizer.js).The
crawlFrameworkPkgs+resolve.noExternalis kept: itnoExternals Svelte component libraries that declare asveltepeer dependency but nosvelteexport condition, whichvite-plugin-sveltetreats as "semi-framework" packages and does notnoExternal(packages/vite-plugin-svelte/src/utils/options.js).Testing
@astrojs/svelteunit suite — 33 pass, including a dev-server SSR test that fails onvite-plugin-sveltev7 without this fix.@astrojs/cloudflaresuite — 215 pass, including a prerender test that renders a Svelte component importing.sveltefiles fromnode_modules.client:*directive, HMR, MDX, nested frameworks, slots, lifecycle).Docs
A changeset file has been added because I want to release this in the next alpha publishing.