storybookjs / addon-svelte-csf

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

[Bug] cannot use some names in imports #167

Open oxymc opened 5 months ago

oxymc commented 5 months ago

Describe the bug

Can't use: import { Menu } from './index'; in index.stories.svelte (but it works, if 'Menu' will be changed by other word: 'DropdownMenu' for example)

Steps to reproduce the behavior

  1. Create a new sveltekit app: npm create svelte@latest <name-of-app>
  2. Now add storybook npx storybook init
  3. Now add Svelte CSF
  4. Reproduce the issue

Expected behavior

More details are in screenshots

Screenshots and/or logs

Знімок екрана 2024-01-29 о 09 15 32 Знімок екрана 2024-01-29 о 09 18 06

Environment

Additional context

Will be good to know which words are 'forbidden' too, but will be great to fix it :)

j3rem1e commented 5 months ago

Do you have a repo where I can look ?

Import should be analyzed with a warning/Reallocation of the story with the same name.

basselalsayed commented 1 month ago

For me the issue comes with import "conflicts"

// menu.svelte

import { Menu } from './menu-base.svelte';

=> docgen error, object is not extensible

if we rename to

import { Menu as Base } from './menu-base.svelte';

it works.

I wasn't sure if the error came from this library, storybook, vite or esm lol

JReinhold commented 1 month ago

@basselalsayed can you share a repository that demonstrates this problem?

basselalsayed commented 1 month ago

@JReinhold yeah here you go https://github.com/basselalsayed/svelte-storybook-csf-issue

in select.svelte, try renaming the import and it works fine