-
-
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
Clear decorators on module dispose #335
Conversation
The `config.js` file acts as the main entrypoint for users storybook code. Stories, decorators etc. are added from here. When webpack HMR replaces this module global decorators get applied repeatedly. This happens because although the config.js file gets replaced the storybook module remains unchanged along with all global decorators we may have added before the replacement. It is okay to remove all decorators when config.js module gets replaced because we can be sure that they'll be added again when config.js file gets executed.
Fixes #284 |
Looks great to me. |
FYI after updating to latest version of Storybook, this bug seems to have been re-introduced. I use a global wrapper and every hot reload adds one (or many) more wrappers. For now, I've imported and added clearDecorators(); in my config.js, which solves the issue but seems this should still be implemented like it was before (haven't had this issue in the past year, using the same setup, only since v 6.0.27) Cheers (my file now looks like this, but without clear I get the issue.)
I use CSF
|
cc @tmeasday |
What happened in 6.0.27 @shilman? @francoismajor -- I think the issue would be solved if you used |
@tmeasday No reason, I followed some tutorial for setup and that's the way it was done ;) I see the docs do it differently now. main.js, and preview.js for decorators. I figured something might have changed in the way to setup everything but couldn't spot what. I'll give this a try and see if that solves it. |
@francoismajor it shouldn't be necessary but I think it'll workaround the issue anyway. Do you have an exact version where the issue started to appear? i.e. did it work in |
@tmeasday no, we went from |
Hmm, ok thanks. |
Okkkk. This is the guide I didn't read when I updated 🤦 There's lots of things in there that apply to my current setup... https://medium.com/storybookjs/storybook-6-migration-guide-200346241bb5 So, just forget I mentioned anything 😅 , I'll go through and do a proper update and I'm pretty sure everything'll be great. Thanks for the quick replies. |
I guess so although I think there may still be a bug here. I guess we'll see if anyone else runs into it. Good luck! |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 6674abc. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
The
config.js
file acts as the main entrypoint for users storybookcode. Stories, decorators etc. are added from here. When webpack HMR
replaces this module global decorators get applied repeatedly. This
happens because although the config.js file gets replaced the storybook
module remains unchanged along with all global decorators we may have
added before the replacement.
It is okay to remove all decorators when config.js module gets replaced
because we can be sure that they'll be added again when config.js file
gets executed.