Skip to content

Improve HMR#10017

Merged
devongovett merged 4 commits into
v2from
hmr-fixes
Nov 24, 2024
Merged

Improve HMR#10017
devongovett merged 4 commits into
v2from
hmr-fixes

Conversation

@devongovett

Copy link
Copy Markdown
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.

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