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

[Bug] Custom errors thrown during build are being swallowed by Vite #221

Closed
JReinhold opened this issue Oct 23, 2024 · 2 comments · Fixed by #222
Closed

[Bug] Custom errors thrown during build are being swallowed by Vite #221

JReinhold opened this issue Oct 23, 2024 · 2 comments · Fixed by #222
Labels
bug Something isn't working prerelease This change is available in a prerelease.

Comments

@JReinhold
Copy link
Collaborator

JReinhold commented Oct 23, 2024

FALSE, SEE COMMENT BELOW

Describe the bug

The following stories file has two stories with the same name "Default". It should throw a nice error here because this is not valid. But it doesn't. dev just ignores it, and build crashes with a hard to parse Vite error.

<script lang="ts" context="module">
    import { defineMeta } from '@storybook/addon-svelte-csf';

    const { Story } = defineMeta({
        title: 'Cart/VoucherForm',
        component: VoucherForm,
    });
</script>

<script lang="ts">
    import VoucherForm from '@components/Cart/VoucherForm.svelte';
    import { expect, within } from '@storybook/test';
    import type { ComponentProps } from 'svelte';

    import { allModes } from '$storybook/modes';
</script>

{#snippet template(args: ComponentProps<VoucherForm>)}
    <VoucherForm {...args} />
{/snippet}

<Story
    name="Default"
    children={template}
/>

<Story
    name="Default"
    children={template}
/>
@JReinhold JReinhold added the bug Something isn't working label Oct 23, 2024
@JReinhold
Copy link
Collaborator Author

In dev I get the proper error when visiting the story (so you might miss this):

21:43:29 [vite] Internal server error: Duplicate exportNames found between two '<Story />' definitions in stories file: file:///Users/jeppe/dev/temp/svelte-csf-conflicts/src/stories/Button.stories.svelte

First instance: <Story name="Primary" exportName="Primary" ... />
Second instance: <Story name="Primary" exportName="Primary" ... />

This can happen when 'exportName' is implicitly derived by 'name'.
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" ... />.

More info: https://github.com/storybookjs/addon-svelte-csf/blob/v5.0.0-next.7/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0006

  Plugin: storybook:addon-svelte-csf-plugin-post
  File: /Users/jeppe/dev/temp/svelte-csf-conflicts/src/stories/Button.stories.svelte

In build I get a bad error:

=> Failed to build the preview
TypeError: Cannot set property message of  which has only a getter
    at enhanceRollupError (file://./node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:65318:15)
    at build (file://./node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:65456:5)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async build (./node_modules/@storybook/builder-vite/dist/index.js:58:230)
    at async Promise.all (index 0)
    at async Module.build2 (./node_modules/@storybook/builder-vite/dist/index.js:58:5160)
    at async Promise.all (index 0)
    at async buildStaticStandalone (./node_modules/@storybook/core/dist/core-server/index.cjs:46960:3)
    at async withTelemetry (./node_modules/@storybook/core/dist/core-server/index.cjs:47080:12)
    at async build (./node_modules/@storybook/core/dist/cli/bin/index.cjs:2841:3)

@JReinhold JReinhold changed the title [Bug] No error is shown when multiple stories have the same name/exportName [Bug] Custom errors thrown during build are being swallowed by Vite Oct 24, 2024
@shilman
Copy link
Member

shilman commented Oct 25, 2024

🚀 Issue was released in v5.0.0-next.8 🚀

@shilman shilman added the prerelease This change is available in a prerelease. label Oct 25, 2024
@xeho91 xeho91 linked a pull request Oct 25, 2024 that will close this issue
@xeho91 xeho91 closed this as completed Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prerelease This change is available in a prerelease.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants