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

Improve HMR #10017

Merged
merged 4 commits into from
Nov 24, 2024
Merged

Improve HMR #10017

merged 4 commits into from
Nov 24, 2024

Conversation

devongovett
Copy link
Member

  • Supports HMR across dynamic import boundaries by ensuring that updates bubble properly through runtime assets. This did not work previously because the runtime uses parcelRequire to load a module by id, so a dependency was never added to the graph. The HMR runtime relies on dependencies being declared so it can traverse parents. In this PR we track the ids that are parcelRequireed and add them in the dev packager so that we can travers from the child through runtimes.
  • We added a query parameter to URL dependency runtimes so that updating them forced them to reload. However, we do not want this for dynamic imports or multiple copies of JS bundles will be loaded. We don't need to force JS bundles to reload (in fact we don't want them to) because the HMR runtime replaces them in place.
  • If module.hot.accept decides that it cannot handle an update for whatever reason, it can call getParents and return additional assets to bubble to. However, we previously only bubbled to those direct parents and no further. This PR fixes that so that we continue bubbling, and reload if not accepted.
  • Fixed another issue where a resolver could return a priority (e.g. the glob resolver), but this was overwritten in core the next time it was resolved instead of merging. Solved similar to how we did for meta.

@devongovett devongovett merged commit 79c8d98 into v2 Nov 24, 2024
17 checks passed
@devongovett devongovett deleted the hmr-fixes branch November 24, 2024 23:45
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

Successfully merging this pull request may close these issues.

1 participant