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

bubbled info in accept handlers #13

Open
rixo opened this issue Jun 12, 2020 · 1 comment
Open

bubbled info in accept handlers #13

rixo opened this issue Jun 12, 2020 · 1 comment

Comments

@rixo
Copy link

rixo commented Jun 12, 2020

I've learned empirically that it can be useful to have a way to tell, from an accept handler, whether it is called because of a direct update hitting the auto accepting module, or if has bubbled from a dependency.

In rollup-plugin-hot, it's implemented as a bubbled argument that is passed to the handler.

The practical use case is CSS injection in svelte-hmr. When a Svelte component is modified, it checks whether only the CSS part has actually changed and, in this case, it does a softer CSS injection -- which is some orders of magnitude safer than recreating stateful JS components and tinkering with DOM elements.

However, it can only do that safely if it is sure that the update came from the component's file itself, and not one of its dependency. If the update has bubbled from a dependency, then the module still need to be reloaded to reflect the change.

@FredKSchott
Copy link
Owner

I'm +1 on this! The reasoning makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants