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

Angular lazy load stories #9831

Closed
thomasoreilly opened this issue Feb 12, 2020 · 8 comments
Closed

Angular lazy load stories #9831

thomasoreilly opened this issue Feb 12, 2020 · 8 comments

Comments

@thomasoreilly
Copy link

Is your feature request related to a problem? Please describe.
Slow initial load when storybook has a large amount of stories.

Describe the solution you'd like
Ability to lazy load Angular stories.

Describe alternatives you've considered
I tried async imports to no avail.

Are you able to assist bring the feature to reality?
Maybe

Additional context
I don't have any

@shilman
Copy link
Member

shilman commented Feb 12, 2020

cc @ndelangen @tmeasday

@tmeasday
Copy link
Member

@thomasoreilly -- what went wrong with async imports? I believe that folks using the Stencil framework (web components) are successfully doing that with SB. Perhaps there is some webpack changes needed in the Angular preset?

Aside from that it would be nice if Storybook officially supported async stories so that addons knew when async story had finished rendering. But my understanding is things mostly work if you can get the mechanics going.

@thomasoreilly
Copy link
Author

Hey @tmeasday.
Would you know where I can find an example of Stencils implementation?

What I've tried is to dynamically load the story's example component using the import('myExampleComponent').
When the promise resolves, then I create the story. This splits the code, however it is still loaded on first load. Also direct resolving a story link is failing.

I'd like to be able to only load the split bundle per story example component on route change. A possible solution would be to pass in a promise as the story function which could handle the resolve.

@tmeasday
Copy link
Member

Yeah, I don't have an open source example I can point you to (maybe @shilman does?) but my understanding was that the stories themselves were loaded syncronously but the components themselves were loaded async. Which sounds like what you describe as the possible solution. I think(?) this might be built into Stencil natively.

@shilman
Copy link
Member

shilman commented Feb 14, 2020

There are lots of stencil example repos linked here: #4600

I'm not sure which is a "best practice" implementation unfortunately. (Would love to figure that out!)

@thomasoreilly
Copy link
Author

Thanks @shilman.

I had a quick look through that PR and may have found an idea to try out. It's not ideal though.
We might be able to wrap the Angular component with a React component and use the useCustomElement hook. Next I can use the lazy load function within Reacts tooling on the wrapper. This was designed for Web Components so not sure if it will work.

@stale
Copy link

stale bot commented Mar 12, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Mar 12, 2020
@stale
Copy link

stale bot commented Apr 11, 2020

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

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

3 participants