storybookjs / addon-svelte-csf

[Incubation] CSF using Svelte components.
MIT License
98 stars 29 forks source link

[Bug] CSF Story Error #149

Closed brittneypostma closed 8 months ago

brittneypostma commented 8 months ago

Describe the bug

Storybook version 7.4.6 also happens with version 7.5.1 addon-svelte-csf version 4.0.9

When loading csf and then attempting to write a story using it, there is an error that the Button import has already been declared.

Steps to reproduce the behavior

  1. New project with SvelteKit and Storybook addon-svelte-csf
  2. Add '@storybook/addon-svelte-csf' to addons array in main.ts
  3. Create a basic button component
    
    <script>
    export let primary = false;
    </script>

<button type="button" on:click class:primary {...$$restProps}>

4. Add a story, `Button.stories.svelte`

<Story name="Primary" args={{ primary: true }} id="primary">


5. Load storybook and navigate to Button stories
6. See `redeclaration of import Button` error on any story under Button

### Expected behavior

To see the Button stories when navigating to them instead of an error.

### Screenshots and/or logs

No extra logs in terminal, but this is the error in Firefox.
<img width="533" alt="image" src="https://github.com/storybookjs/addon-svelte-csf/assets/45889730/06987479-0139-40d8-a23a-7b2913d6ea41">

And in Chrome:
<img width="857" alt="image" src="https://github.com/storybookjs/addon-svelte-csf/assets/45889730/829303dd-0a56-455e-8607-77748a71194a">

### Environment

 - OS: iOS
 - Node.js version: 20
 - NPM version: 8.19.4
 - Browser (if applicable): chrome and firefox
 - Device (if applicable): desktop
j3rem1e commented 8 months ago

Your story is named "Button" which generate an "export const Button = ..."

You can rename your story or rename the import Button.

We can probably improve the error message but I don't think it's possible to automatically let it works

brittneypostma commented 8 months ago

Yeah, I just actually got it working and was coming back to say this. I think the error message is a little confusing.