- Notifications
You must be signed in to change notification settings - Fork72
Emulate HMR bubbled argument to enable svelte-hmr CSS only updates#166
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
CC@Smittyvb as well in case you'd like an extra pair of eyes for testing it |
I've been using this branch for like a month, haven't found something that would drive me off. As to unrecoverable errors and stuff I feel like the situation is same, but the ability to do state-saving css reload was added, which is important. @rixo what do you think, is there a possibility of regressions related to HMR with this ? |
It seems that the approach of replacing just css doesn't work well with conditional markup. |
@non25 Funny you come up with that now. We identified the problem yesterday in the Vite plugin. It's because the compiler only apply the component scoping class to elements that it sees are actually matched by a selector. This means, when you add a selector CSS only updates are not enough. Will have to reduce the cases where we do a CSS only update to fix that for now. Eventually, we can search for a solution, probably with the help of the compiler. Maybe scoping everything in dev/hot would be the most straightforward, even if it's a bit concerning for HMR to change behavior so much as compared to prod.
You do know of the magic comments that let you override this temporary at component level, without the need for restarting the dev server, right? |
This emulates the
bubbled
accept handler argument over Webpack HMR API, which allowssvelte-hmr
to detect CSS-only changes and skip recreating the whole component in those cases.I'm not entirely confident in the correctness of the implementation... I suspect, in particular, that it could wrongly resolve
bubbled
tofalse
in some cases, but to trigger those conditions the non-CSS code of the component would necessarily have changed, which meansbubbled
wouldn't be used bysvelte-hmr
anyway.Still, this might require a bit of in-depth testing to ensure I haven't missed something, so I'm making a draft PR for now.
@non25 Can you help testing this change, and report if everything is in place and the fix works correctly?