Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
rixo wants to merge1 commit intosveltejs:master
base:master
Choose a base branch
Loading
fromrixo:hmr-bubbled

Conversation

rixo
Copy link

This emulates thebubbled 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 resolvebubbled 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?

non25 reacted with thumbs up emojinon25 reacted with hooray emojinon25 reacted with heart emojinon25 reacted with rocket emojinon25 reacted with eyes emoji
@benmccann
Copy link
Member

CC@Smittyvb as well in case you'd like an extra pair of eyes for testing it

@non25
Copy link
Contributor

I've been using this branch for like a month, haven't found something that would drive me off.
Sadly it can't successfully replace css when usingsvelte-pathfinder as a router.
Here's repro:https://github.com/non25/svelte-template-webpack/tree/test-hmr-bubbled

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 ?
I don't even know how we would reliably test something like this.

@non25
Copy link
Contributor

It seems that the approach of replacing just css doesn't work well with conditional markup.
Toggling conditional markup after HMR css update results in no css for that markup.
Will edit in a repro later.
Have to resort topreserveLocalState: true for current task, works better.

@rixo
Copy link
Author

toggling conditional markup after HMR css update results in no css for that 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.

Have to resort to preserveLocalState: true for current task, works better.

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?

non25 reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@rixo@benmccann@non25

[8]ページ先頭

©2009-2025 Movatter.jp