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 6.4] HMR is ignored when making changes in preview.js #17767

Closed
yannbf opened this issue Mar 20, 2022 · 10 comments
Closed

[Storybook 6.4] HMR is ignored when making changes in preview.js #17767

yannbf opened this issue Mar 20, 2022 · 10 comments

Comments

@yannbf
Copy link
Member

yannbf commented Mar 20, 2022

Describe the bug

Title is descriptive, and here's a video for more context:

Screenshare.-.2022-03-19.11_13_08.AM.mp4

This is the error:
image

To Reproduce
1 - sb repro for CRA or any other
2 - run Storybook
3 - make changes in preview.js

@tmeasday
Copy link
Member

@yannbf in SSv6, we do force a full reload when you make a change to preview.js.

In official Storybook, I see:

image

and the page reloads. That looks like that's not what's happening here?

@tmeasday
Copy link
Member

tmeasday commented Mar 21, 2022

Looks like this is an issue with webpack 5, not sure there's much we can do (beyond push people to ssv7): webpack-contrib/webpack-hot-middleware#390

@yannbf to confirm this was a WP5 project (you mention CRA)?

@rikkit
Copy link

rikkit commented Mar 23, 2022

I am also experiencing this issue, non-CRA app, plain Storybook with Yarn 2 Pnp and Webpack 5. I think it's fair to say hot reload is pretty core to the Storybook dev experience so any alternative setups are welcome...

@tmeasday What's ssv7?

Edit: using the resolution specified here helps a bit - the preview reloads on change, which is not so bad for now. webpack-contrib/webpack-hot-middleware#390 (comment)

@tmeasday
Copy link
Member

tmeasday commented Mar 24, 2022

@rikkit, sorry, the storyStoreV7 feature.

Edit: using the resolution specified here helps a bit - the preview reloads on change, which is not so bad for now. webpack-contrib/webpack-hot-middleware#390 (comment)

That's the correct behaviour in the v6 version of the story store. For various boring technical reasons we need to reload the browser if you change preview.js; this is a limitation we removed in the v7 store.

@jrmyio
Copy link

jrmyio commented May 6, 2022

I get the same issue with @storybook/builder-vite and storyStoreV7 enabled. Vite starts refetching (instead of HMR) all dependencies when any of the dependencies that are used in preview.tsx are edited.

For example, when using a StyledComponents theme (provided by ThemeProvider inside the preview.tsx), the entire preview refreshes when I change the provided theme.

@tmeasday
Copy link
Member

tmeasday commented May 9, 2022

@jrmyio I'm not totally sure about the Vite builder. @IanVS - is it expected to do a full refresh on preview.tsx changes (even with Story Store v7`)?

@IanVS
Copy link
Member

IanVS commented May 9, 2022

I do see that as well, now that I look. I've been fiddling with it a bit, and I can get HMR to work, but I'm not happy with the solution so far. I'll put up a PR in the next day or two and see if I can get some help from @joshwooding.

@codebutler
Copy link

I'm also using the vite builder, storyStoreV7, and have to manually refresh the browser after changing the theme (in my case using chakra-ui).

@IanVS Can you please share your workaround for this issue? Thanks.

@tmeasday
Copy link
Member

tmeasday commented Apr 3, 2023

@codebutler this issue is fixed in SB7 (HMR on preview.js in vite).

@IanVS IanVS closed this as completed Apr 3, 2023
@IanVS
Copy link
Member

IanVS commented Apr 3, 2023

I've closed this because I believe the issue is fixed in both webpack and vite in Storybook 7. If someone is still having problems with the latest version of Storybook, please let us know.

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

8 participants