storybookjs / addon-svelte-csf

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

[Bug] Autodocs produce invalid code example #166

Closed sacrosanctic closed 5 months ago

sacrosanctic commented 5 months ago

Describe the bug

show code section produces code examples that look like <Proxy<RenderContext> /> when using the following:

<Template let:args>
  <MyComponent {...args} />
</Template>

Steps to reproduce the behavior

Repro

  1. npm i
  2. npx storybook@latest init
  3. npm i --save-dev @storybook/addon-svelte-csf
  4. add stories
  5. npm run storybook
  6. view NotWorking and Working and click show code

Expected behavior

Should say:

Screenshots and/or logs

image

j3rem1e commented 5 months ago

When you use "args" stories, the code is generated by Storybook (and not this addon) When you don't use "args" stories, the code is extracted from the svelte template.

the "Proxy<..>" is used by svelte-hmr when vite is used, and the component can't be parsed by Storybook/svelte-docgen parser. However, I thought this issue had been fixed in storybook in the v7.6 branch.

j3rem1e commented 5 months ago

Well, sorry. but nothing I can do on my side, so i'll close this issue.

it should only happen in dev mode, when the vite hmr is used, not in a real prod build. The vite proxy doesn't have a way to get the added hidden __docgen field. You can maybe create an issue in the storybook repo, but I think there are already severals.