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

Storybook v6.1.5 with Svelte fails to start #13247

Closed
j3rem1e opened this issue Nov 24, 2020 · 10 comments
Closed

Storybook v6.1.5 with Svelte fails to start #13247

j3rem1e opened this issue Nov 24, 2020 · 10 comments
Assignees
Milestone

Comments

@j3rem1e
Copy link
Contributor

j3rem1e commented Nov 24, 2020

Describe the bug

Storybook v6.1.5 doesn't work with Svelte if a story use a component with a mandatory property.

To Reproduce

Create a Story with a Svelte component which assume a property is set.

For example :

<script>
  export let myFunction;
  myFunction();
</script>

It's related to this PR by @BlackFenix2 : #12347
In this PR, every component are instanciated without properties, in order to extract the generated documentation here : https://github.com/storybookjs/storybook/blob/next/addons/docs/src/frameworks/svelte/extractArgTypes.ts#L37
It doesn't work if the component has mandatory properties.

More over, it assumes every component have a docgen here : https://github.com/storybookjs/storybook/blob/next/addons/docs/src/frameworks/svelte/extractArgTypes.ts#L48
This not always the case (if a component doesn't have any property, then docgen will be undefined but I am not 100% sure about that). If a component have docgen is not defined, then the Storybook doesn't starts.

@sdwvit
Copy link

sdwvit commented Nov 24, 2020

@j3rem1e same issue here, rolling back to 6.0.12 fixes the problem in my project

@shilman shilman added this to the 6.1.x milestone Nov 24, 2020
@shilman shilman self-assigned this Nov 25, 2020
@j3rem1e
Copy link
Contributor Author

j3rem1e commented Dec 5, 2020

Any news on this issue ?

Creating every components is probably not a good idea, it causes a lot a side effects, like this issue or #13351

@shilman
Copy link
Member

shilman commented Dec 6, 2020

Boo-yah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-alpha.4 containing PR #13386 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Dec 6, 2020
@shilman
Copy link
Member

shilman commented Dec 12, 2020

Boo-yah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.11 containing PR #13386 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

@j3rem1e
Copy link
Contributor Author

j3rem1e commented Dec 16, 2020

I tested to upgrade to 6.1.11, but it doesn't really work. My storybook starts now, but most of the stories are break.

Svelte is not robust when there is exception in the initialisation of a component. the global state can be corrupted.
Instanciating all components without properties at startup cause this kind of corruptions and unexpected side effects.

Is there a way to opt-out of this function ?

btw, i can't reopen this issue @shilman

@j3rem1e
Copy link
Contributor Author

j3rem1e commented Dec 16, 2020

I have a working patch to make it works without instanciating every components :

I have changed the webpack svelte docgen to be a post processor (was a preprocessor). Then in this loader, I give the component source to the svelte docgen parser and inject a __docgen static field into the class.

In extractArgTypes, I can then just get the docgen properties with component.__docgen without instanciating the component.

@BlackFenix2 is it an acceptable solution for you ?

@shilman shilman reopened this Dec 16, 2020
@shilman
Copy link
Member

shilman commented Dec 16, 2020

@j3rem1e Is that something you can PR?

@BlackFenix2
Copy link
Contributor

@j3rem1e sounds good, i prob should of made the __docgen property static anyway. If this works locally in the svelte example for you fell free to submit a PR.

@shilman
Copy link
Member

shilman commented Dec 20, 2020

Zoinks!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.0-alpha.9 containing PR #13466 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

@shilman
Copy link
Member

shilman commented Jan 12, 2021

Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.14 containing PR #13466 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants