-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Describe the bug
Having a comment before the call to defineMeta() can break the story in some cases.
In that case this error is shown in the console and UI:
[vite] Internal server error: Cannot add property 0, object is not extensible
Plugin: storybook:addon-svelte-csf
File: D:/code/svelte-insertDefineMetaParameters-repro/src/stories/broken.stories.svelte
at Array.push ()
at insertDefineMetaParameters (file:///D:/code/svelte-insertDefineMetaParameters-repro/node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/define-meta/insert-parameters.js:40:60)
at transformDefineMeta (file:///D:/code/svelte-insertDefineMetaParameters-repro/node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/define-meta/index.js:12:5)
at transformStoriesCode (file:///D:/code/svelte-insertDefineMetaParameters-repro/node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/index.js:35:5)
at async TransformPluginContext.transform (file:///D:/code/svelte-insertDefineMetaParameters-repro/node_modules/@storybook/addon-svelte-csf/dist/compiler/plugins.js:91:13)
at async EnvironmentPluginContainer.transform (file:///D:/code/svelte-insertDefineMetaParameters-repro/node_modules/vite/dist/node/chunks/dep-M_KD0XSK.js:31325:14)
at async loadAndTransform (file:///D:/code/svelte-insertDefineMetaParameters-repro/node_modules/vite/dist/node/chunks/dep-M_KD0XSK.js:26407:26)
at async viteTransformMiddleware (file:///D:/code/svelte-insertDefineMetaParameters-repro/node_modules/vite/dist/node/chunks/dep-M_KD0XSK.js:27492:20)
Steps to reproduce the behavior
- Create a new project e.g. using the steps here: https://storybook.js.org/tutorials/intro-to-storybook/svelte/en/get-started/
- Create a story like this:
<script module lang="ts">
import {defineMeta} from '@storybook/addon-svelte-csf';
/* Removing this comment fixes the story */
const {Story} = defineMeta({
// title: 'custom title', // uncommenting this fixes the story
});
</script>
<Story name="Example">
test
</Story>- Navigate to the story
Expected behavior
Having comments shouldn't break the story.
Neither should not specifying a title.
Screenshots and/or logs
If applicable, add screenshots and/or logs to help explain your problem.
Environment
- OS: Windows
- Node.js version: 22.18.0
Additional context
As I wrote in the story code, the problem goes away if either the comment is removed or a title is specified.