-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Framework support - Stencil.js #4600
Comments
New Starter build for Current stencil and SB 5 to be created |
@Edd-Strickland want to work on a stencl support version 🎉 |
I've upgraded the polymer starter with stencil to the latest version of SB need some help in removing polymer and adding in stencil complier now |
Hi, @Edd-Strickland just for information, i have implemented Stencil inside Storybook like you did in your starter, in this project : https://github.com/vogloblinsky/nutrition-web-components I have used the HTML starter of Storybook. For now with Storybook & Stencil, i just had to :
The main problem i think is the usage of Webpack by Storybook to handle JavaScript files imported inside a story. The ideal workflow is to only imported the JS file of the Web Component. |
Yeah this is what have done previously but with the polymer version however what this means is that by importing as plain static W/C implementations is you need to update each time into your story's which feels limiting. |
Hi All, I have created a wrapper that can be installed on a stencil |
looks really good I'll test on Monday. Good work :) |
Will this be made into an official part of Storybook? I have a desperate need for this! |
@o-t-w We're trying, would you be able to help us? |
@ndelangen I would be happy to test things and provide feedback/bug reports. |
Would this work with LitElement (and web components in general) or just Stencil? |
@nisheed2440 your wrapper seems promising, I will test this soon! But it could be great to have a "native" integration documented by Storybook 👌 |
@nisheed2440 I have been very busy(sorry everyone) but have had a very small window today to test a very vanilla version of this locally and it's really good. works really well. going to spend some time on this next week trying to incorporate it into an existing project to see how this might work for existing stencil users / projects. |
I have tested it this morning and it works pretty well too! GJ it's really easy to setup. I have installed and tested some addons:
Everything works fine, just found one issue with addon-knobs #5017 But there is a workaround and this should be fixed pretty soon I think. |
I spent the last 2 weeks playing with StencilJS and Storybook and did a livestream where I cover my solution. I feel there is a much better way, but I was able to get HMR, and most plugins to work with little issue. Would love any feedback you guys have on how to improve or import the loaders from the distribution stencil bundle. https://www.youtube.com/watch?v=XwHtPw3izLE And here is the repo! ^_^ |
@nisheed2440 Hello, i m using an approach very similar to yours and everything is working expect chromatic. were you able to make chromatic work with stencil/storybook? |
@nisheed2440 Thank you so much for this really great effort. Hopefully this gives the team here a head start in the right direction. Stencil and Storybooks are ideal for each other. |
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! |
Anybody want to pick this up? |
My team is using StencilJS + Storybook for our common component library and I'd love to contribute. Maybe a few of us can get this thing back on track... |
Seems like there's a lot of interest, e.g. https://twitter.com/dboskovic/status/1120336958008348672 One easy win would be publishing a I'd be happy to guide anybody who wants to pick that up. |
Great question, I did not try with |
@DominicPieper, unfortunatelly, I've already removed the story as I was playing with it around :( |
@marcolanaro I'll spend some time at the weekend. Until now, everything I tried failed with just no stories visible |
Ok, I've done some more investigations and looked into the compiler. I can now run only storybook, no need for a separate In
In
So now you can avoid depending on the stencil build in
And the story will look something like this:
I'm sure there is still plenty of work to do and plenty of scenarios to address, but I think this is a great step forward. |
@marcolanaro I'd love to discuss how to move the PR forward. Can you jump onto our Discord server and chat me? https://discord.gg/storybook |
You are right, we should do it. |
my solution with the proxy before can HMR in stencil and storybook. cheers |
Hey all, I'm the PM on the Stencil team and I'm looking for a roundup of everything in this thread so we can put a super solid plan together for native integration. I recently filed a feature request to gather community signal around allowing Storybook stories to work with Stencil's JSX library. It got a lot of activity! ionic-team/stencil#3104 (while you're there, add some reactions if you want!) Now, I'm trying to determine the best next steps. I'm considering an option where we can have Storybook be an optional primary dev server for Stencil, and it seems like the story authorship/JSX is a big part of that. There's quite a lot of prior art around the dev server side of things, so I want to post my round up of resources that I'm sifting through to help craft a strategy to ship this. First, I'm digging into this PR: #15479 which adds For some other prior art, about 8 months ago, @shilman created a builder for Stencil (Repo located here) which provides a standalone dev server prototype. This could be a boon, as it provides some great samples of what it could take to bring Stencil's dev server integrated as well as its HMR features to work with Storybook out of the box, without the need for a After that, we have a couple other exciting tricks up our sleeves, like creating premium framework wrapper functions (f.k.a. framework output targets) that can produce more helpful framework specific code - including stuff like automatically creating Stories for your React, Angular, and Vue components that are produced from Stencil. This could leverage Storybook's Composition Feature in order to provide an awesome experience for you while you are developing and maintaining your design systems. If any of this is interesting, please add a reaction to this comment! If you have ideas, leads to explore, or any other recommendations, please don't hesitate to reach out to me on the Discord (splitinfinities) or reply to this issue (or the JSX one on Stencil's Github repo) Thanks everyone for the patience! The Stencil team is very excited to help make a great solution so you can document your code effectively, test the different variations of your components, and overall increase adoption of your design systems and component libraries! |
@splitinfinities Would you be interested in a zoom meeting to discuss things? I don't have a ton of background knowledge about stencil, but I know the insides and outsides of storybook. If you're interested, schedule a meeting with me here: |
@splitinfinities of course you have my permission to take my previous work and make it production ready. I actually feel sorry for not being able to push that forward for the community, but I had very busy months at work. I'm still very interested to see storybook as a first class citizen for stencil :) |
@splitinfinities - any update on the Stencil team's effort to give their devs first class storybook support? It looks to me like @marcolanaro's solution above is the state of the art (though it's now a year old), but it has the limitation that it doesn't support HMR. Is that correct? |
Hey all, unfortunately I was let go from the Stencil team last December. I'm not aware of the Stencil projects direction since then. Sorry for the lack of updates on my part, since that timeframe, these tickets weren't in my purview! I may recommend closing this ticket. Folks have been reaching out to me asking about progress on this so I wanted to give an update here to curb some of that. I'm really sorry y'all! As a community member of Storybook, I can share that I have switched to using Lit (https://lit.dev) and ViewComponent (https://viewcomponent.org) with fantastic success! They're well documented and have plenty of great features + integrate with Storybook quite well. Thanks all - I hope you find success with the tools of your choice! |
Thank you for the update @splitinfinities I appreciate the hard work, effort and time you've put in! |
The initial way I developed with stencil & storybook (as described here: https://ionic.io/blog/how-to-use-storybook-with-stencil) required doing production builds, which was fast initially, but quickly slowed down as the project grew. So just to add one more workaround to the mix, offering fast builds via stencil dev mode and page reloads on stencil changes; I do the following:
This seems to work pretty well sofar. |
I can confirm this approach works with Stencil 4.4.0 and Storybook 7.4.6. |
Does anyone have issues running "compiled" stories via |
Here is my take on storybook 8 and stencil with working dev mode hot reloading: the alternative is to use the html5 webpack framework and the BrowserSyncWebpackPlugin |
i finally got Storybook 8 + StencilJS + Vite to work with Hot Reloading too as it turns out, the cause was quite primitive. If you have a look at the documentation of the vite dev server (which storybook uses), there is a very notable hint:
See: https://vitejs.dev/config/server-options.html#server-watch
Simple fix: Put the following configuration into your
or full example:
If anyone is interested, i can provide a full project setup on Github. |
A project on guthub would be great, that way we can track if something is broken in the new releases |
i have Storybook 7.6.17 + Stencil 4.18 + Vite 4 successfully in production. cheers |
🎉 Here you go: https://github.com/rschaufler/stencil-storybook-vite This is a working example of Storybook 8 + Stencil 4 + Vite. Make sure you have pnpm installed. Let me know if you have any questions or feedback. |
Those are all still quite workarounds. Issues:
The proper solution for this problem is to configure storybook to include stencils TS files in its own build in tsconfig so ts will retrigger reload when a stencil ts file changes for that the stenciljs compiler is probably also needed to be used see: I have a working solution with stencil dev build but it needs a custom vite watch and that the stencil build is part of the SB deployment (https://github.com/pfteter/stencil-storybook-8-vite-integration-dev-build/blob/main/README.md) |
Never claimed its not a workaround, but its the least intrusive in my opinion.
what does preview.ts has to to with a stencil production build?
All solutions (including yours) have storybook running alongside stenciljs. Where do you take the full production build from? Storybook /StencilJS runs the dev script. And where do you take the argument with react/angular components from?
Using the repository i provided, its not slow at all and it is in fact "real" HMR. The update is instant and only for the component that was updated (not the whole dist directory). What errors do you expect? How did you measure that it is slow?
Running the StencilJS dev script is also a valid solution.
The solution i provided does not need this. Your solution is working around the core issue that the dist folder is ignored with a hacky vite plugin instead of just adjusting the vite configuration. Apart from that, all your criticism can be applied to your solution as well, so i don't really understand why you come up with this now. |
Just reviewing the solutions, it's not criticsm.
Just saying it's possible to make a solution where we dont need stencil running side by side with storybook that would be the real deal. I'm not saying my solution is good it's just a workaroud too :)
That is a great input, we have a lot of components and try to minimize the initial build it takes almost 2 mins. Again I'm not saying the other solution is better it's a workaround, just saying that probably the best one would be if storybook would have stencil support out of the box without side by side running it's just TS and the stencil compiler that transforms the stencil markup. https://storybook.js.org/addons/storybook-addon-stencil that plugin is half way trough |
Yes, thats for sure. Having native support for StencilJS would be great. But as for now, we have to help ourselves with this kind of workarounds. |
would be similar to that as part of vite build, we just need to compile the stencil to ts files and link them in storybook. But maybe I have a wrong model of it. Anyway would be hard to maintain |
Describe the solution you'd like
I'd like to see Stencil.js support, as I see Storybook to be very component focused, and Stencil being a very component focus framework - these tools would compliment each other very well.
Are you able to assist bring the feature to reality?
yes, I can...
The text was updated successfully, but these errors were encountered: