-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Apply HMR updates in topological order #8752
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mischnic
reviewed
Jan 5, 2023
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached Bundles
React HackerNews ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. AtlasKit Editor ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. |
mischnic
approved these changes
Jan 7, 2023
marcins
pushed a commit
to marcins/parcel
that referenced
this pull request
Jul 14, 2023
* upstream/v2: (33 commits) v2.8.3 Changelog for v2.8.3 Address bug by updating an asset reference and merge conditions (parcel-bundler#8762) Fix CSS order when merging type change bundles (parcel-bundler#8766) fixing failing build for contributors on Linux using Node 18 (parcel-bundler#8763) Extension: Importers View and separate LSP protocol package (parcel-bundler#8747) Bump swc to fix sourcemaps with Windows line endings (parcel-bundler#8756) Apply HMR updates in topological order (parcel-bundler#8752) Make extension packaging work (parcel-bundler#8730) Typed api.storeResult (parcel-bundler#8732) Refactor LSP to use vscode-jsonrpc (parcel-bundler#8728) Bump swc (parcel-bundler#8742) Recursively check reachability when removing asset graphs from bundles in deduplication (parcel-bundler#6004) Fix tsc sourcemaps metadata (parcel-bundler#8734) Assigning to `this` in CommonJS (parcel-bundler#8737) Don't retarget dependencies if a symbol is imported multiple times with different local names (parcel-bundler#8738) Add a note about using flow in CONTRIBUTING.md (parcel-bundler#8731) filter out title execArgv to workers (parcel-bundler#8719) Document more of the BundleGraph class (parcel-bundler#8711) Fixed the hmr connection with host 0.0.0.0 (parcel-bundler#7357) ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue with circular dependencies and HMR. One example is if you had a React context provider, and a consumer that relied on it that was also a dependency of the provider, the context would become null after saving either of these components causing a crash.
In the test example, both of these components do not self accept the update because they don't only export React components (one exports a context, the other exports another function). Therefore, the update bubbles to the root App component which does accept it. However, the other modules still must be re-executed so they use the updated component. But since the dependency is circular,
consumer.js
re-executes first, and thenprovider.js
. So that meansconsumer.js
is still pointing at an old version ofprovider.js
with the old context, which no longer has a value assigned to it.This PR fixes the issue by splitting the HMR accept phase into two:
Since we only re-execute the root-level accepting assets, but their children are already disposed, the children will be re-executed in topological order (the same as when first loading the asset). Splitting this into two phases also matches webpack's behavior more closely.