Skip to content

fix: migrate Legacy*.svelte runtime mocks to Svelte 5 runes syntax#348

Open
XIYO wants to merge 1 commit into
storybookjs:mainfrom
XIYO:fix/legacy-svelte5-runes-vite8-compat
Open

fix: migrate Legacy*.svelte runtime mocks to Svelte 5 runes syntax#348
XIYO wants to merge 1 commit into
storybookjs:mainfrom
XIYO:fix/legacy-svelte5-runes-vite8-compat

Conversation

@XIYO
Copy link
Copy Markdown

@XIYO XIYO commented Apr 4, 2026

Fixes #337

Problem

Vite 8 introduced Rolldown as the bundler, which pre-bundles .svelte files in node_modules via the vite-plugin-svelte:optimize plugin. Rolldown rejects Svelte 4 export let syntax as legacy_export_invalid, causing Storybook to silently render a completely blank preview with no error output.

Affected files:

  • src/runtime/LegacyTemplate.svelteexport let id triggers the error
  • src/runtime/LegacyStory.svelteexport let props trigger the error

Fix

Converted both files from Svelte 4 syntax to Svelte 5 $props() runes:

LegacyTemplate.svelte

- export let id = 'default';
+ const { id = 'default', children }: Props = $props();
+ void id;

LegacyStory.svelte

- export let name: string | undefined = undefined;
- // ... other export lets
+ const { children }: Props = $props();

Why this is safe

These files are mock stubs — they are never actually rendered. Their sole purpose is IDE type support. The real work happens in the Vite pre-transform codemod which rewrites <Template> and <Story> tags into {#snippet} and defineMeta calls at the AST level, before Svelte ever sees the components.

Converting to $props() has zero behavioral impact.

Tested with

  • Vite 8.0.x (Rolldown)
  • Svelte 5.55.x
  • @storybook/sveltekit 10.x

LegacyTemplate.svelte and LegacyStory.svelte used Svelte 4 `export let`
syntax. Vite 8 Rolldown pre-bundles node_modules .svelte files via
vite-plugin-svelte:optimize and rejects `export let` as
legacy_export_invalid, causing a blank Storybook preview.

Converted both files to Svelte 5 $props() runes. These are mock stubs
only — never rendered, only used for IDE type support. The pre-transform
codemod still handles the actual AST rewrite before Svelte compilation.
No behavioral change.

Fixes storybookjs#337
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 4, 2026

🦋 Changeset detected

Latest commit: 5ce1f92

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@storybook/addon-svelte-csf Patch

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

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.

[Bug] Full runes mode support

1 participant