This document is a list of known errors that this addon throws.
No module context was found in the stories file.
This often happens if you call defineMeta(...)
in a regular instance script (<script>
) and not in a module script (<script module>
), which is required.
Ensure the stories file which caused this error has the following initial code:
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
const { Story } = defineMeta({
// define your stories meta here
});
</script>
A default or namespace import was used to import from this addon package, which is not supported. Only named imports are supported (this only applies to imports from @storybook/addon-svelte-csf
).
Change your import to a named import instead:
- import svelteCsf from "@storybook/addon-svelte-csf";
+ import { defineMeta } from "@storybook/addon-svelte-csf";
No import of defineMeta
from this addon package was found in the module context.
You might have forgotten to import it:
<script module>
+ import { defineMeta } from "@storybook/addon-svelte-csf";
...
</script>
No variable declaration from the defineMeta()
call was found. While you might have called defineMeta()
, its result needs to be assigned to a variable:
<script module>
import { defineMeta } from "@storybook/addon-svelte-csf";
- defineMeta(...);
+ const { Story } = defineMeta({
+ // define your stories meta here
+ });
</script>
No destructured Story
component was found in the variable declaration with the defineMeta()
call.
The Story
component might have been incorrectly created:
<script module>
- const Story = defineMeta({
+ const { Story } = defineMeta({
// define your stories meta here
});
</script>
The first argument to the defineMeta()
call was invalid.
It must be a valid object expression with the same structure as the Default export in CSF.
<script module>
- const { Story } = defineMeta();
+ const { Story } = defineMeta({
+ title: 'Path/To/MyComponent',
+ component: MyComponent,
+ decorators: [ ... ],
+ parameters: { ... },
+ });
</script>
A <Story>
component received an invalid children
prop. If set, the children
prop must be a reference to a snippet defined in the root scope file. Eg.:
{#snippet template()}
<span>🚀</span>
{/snippet}
<Story name="Rocket" children={template} />
This error indicates that the children
prop was passed, but it was not correctly referencing a snippet.
setTemplate()
was called to set a default snippet, but the argument passed was not a reference to a root-level snippet in the file.
Below is a demonstration of correct usage:
<script>
setTemplate(template);
</script>
{#snippet template()}
<!-- ... -->
{/snippet}
Storybook stories indexer parser threw an unrecognized error. If you see this error, please report it on the issue tracker on GitHub.
Note
The errors in this category are most likely internal bugs during parsing of the compiled output rather than caused by users' invalid code.
The import of defineMeta
from this addon could not be found while parsing the compiled code.
If you get this error, please open a bug report with detailed reproduction steps including the code that caused the error.
https://github.com/storybookjs/addon-svelte-csf/issues/new
A variable declaration with the defineMeta
call could not be found while parsing the compiled code.
If you get this error, please open a bug report with detailed reproduction steps including the code that caused the error.
https://github.com/storybookjs/addon-svelte-csf/issues/new
A default export could not be found while parsing the compiled code. The Svelte compiler should automatically default export a component, but this couldn't be found for some reason.
If you get this error, please open a bug report with detailed reproduction steps including the code that caused the error.
https://github.com/storybookjs/addon-svelte-csf/issues/new
A Story
identifier could not be found while parsing the compiled code.
If you get this error, please open a bug report with detailed reproduction steps including the code that caused the error.
https://github.com/storybookjs/addon-svelte-csf/issues/new
A main function component could not be found while parsing the compiled code.
If you get this error, please open a bug report with detailed reproduction steps including the code that caused the error.
https://github.com/storybookjs/addon-svelte-csf/issues/new
A Story-component's props could not be extracted as an object expression from the compiled code.
If you get this error, please open a bug report with detailed reproduction steps including the code that caused the error.
https://github.com/storybookjs/addon-svelte-csf/issues/new
The component
property in defineMeta
was not referencing an imported Svelte component.
It expected an identifier to a Svelte component but got something else.
Ensure you're using the correct syntax, following the example below:
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import Button from './Button.svelte';
const { Story } = defineMeta({
component: Button,
});
</script>
Our parser spotted an invalid schema on the variable declaration from the defineMeta
call.
You most likely forgot to destructure the return value.
- const Story = defineMeta({
+ const { Story } = defineMeta({
component: Button,
});
When analysing the object passed to defineMeta({ ... })
, invalid properties were found. The following properties must be static string literals, but got something else:
title
name
Dynamically generating these properties with functions or with template strings is not supported.
When analysing the object passed to defineMeta({ ... })
, invalid properties were found. The tags
property must be a static array of static string literals, but got something else
Dynamically generating the array or the entries with functions or with template strings is not supported.
When analysing the object passed to defineMeta({ ... })
, invalid properties were found. The tags
property must be a static array of static string literals, but got something else
Dynamically generating the array or the entries with functions or with template strings is not supported.
When analysing one of the <Story />
definitions, a static literal string was expected but found something else.
The following props to the Story
component must be a static literal string:
name
exportName
Dynamically generating the string is not supported, eg. with a function or with template string.
Examples of valid syntax:
<Story name="Default" />
<Story exportName="MyComponent" />
When analysing one of the <Story />
definitions, a static array of static literal strings was expected but found something else.
The tags
prop to the Story
component must be a static array of static literal strings.
Dynamically generating the array or the strings is not supported, eg. with a function or with template strings.
Examples of valid syntax:
<Story tags={['autodocs', '!dev']} />
When analysing one of the <Story />
definitions, a static array of static literal strings was expected but found something else.
The tags
prop to the Story
component must be a static array of static literal strings.
Dynamically generating the array or the strings is not supported, eg. with a function or with template strings.
Examples of valid syntax:
<Story tags={['autodocs', '!dev']} />
When analysing one of the <Story />
definitions, no name
or exportName
was found.
Please ensure that every <Story />
component uses one or both of these attributes, see example below:
<Story name="My Story" />
<!-- or ... -->
<Story exportName="MyStory" />
<!-- or ... -->
<Story name="My Story" exportName="OtherExportName" />
The exportName
prop in a <Story />
component is not a valid JavaScript variable name.
It must be a valid JavaScript variable name.
It must start with a letter, $
or _
, followed by letters, numbers, $
or _
.
Reserved words like default
are also not allowed (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_words).
Multiple <Story />
components have duplicate export names.
This can happen when exportName
is implicitly derived by name
attribute.
Complex names will be simplified to a PascalCased
, valid JavaScript variable name,
eg. Some story name!!
will be converted to SomeStoryName
.
You can fix this collision by providing a unique exportName
prop with<Story exportName="SomeUniqueExportName" ... />
.
See more in the exportName
API docs.
<Story/>
component prop template
value must be a text with string reference to existing <Template />
's id
prop.
It cannot be a shorthand or a dynamic value.
<Story
- template
- template={dynamicId}
+ template="custom-template"
/>
You are using legacy template API, with deprecated components.
To enable support for legacy API, tweak this addon options in your (./.storybook/main.(j|t)s
) file:
See the Legacy API section for more details.
addons: [
// ... other addons
- '@storybook/addon-svelte-csf',
+ {
+ name: '@storybook/addon-svelte-csf',
+ options: {
+ legacyTemplate: true,
+ },
+ },
],
You have more than one unidentified <Template>
components (without an id
prop) in your stories file.
This leads to unwanted behaviour at runtime.
To solve this issue, assign an id
prop to the other <Template>
(s) components.
- <Template>
+ <Template id="template-1">
And for the stories <Story />
component(s) which are supposed to use this template, use the template
prop with id as string reference.
- <Story>
+ <Story template="template-1">