-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Allow both HMR clients and live reloading clients #6837
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the single required change to make this work but I'm not sure what would be the best way to support this feature without affecting HMR performance.
The problem is that inside of
_hmrFileChangeListener
lots of things happen asynchronously so if you remove thereturn
those async operations will compete for CPU and IO with the Live Reload changes. For Live Reload it doesn't matter if the change takes a couple more of milliseconds but for HMR it does.Even if we turn
_hmrFileChangeListener
into a function that returns a promise and wait to execute the other listeners, we'll end up slowing the HMR codepath because the code is not injected on the client until the sourcemaps for the new file are requested and returned (seereact-native/Libraries/Utilities/HMRClient.js
Lines 112 to 135 in 235b16d
For this change to not affect performance we'll need to also include the sourcemaps on the original request response.
cc @satya164
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes of other two files(RCTDevMenu.m and DevServerHelper.java) avoid the clients process both
onchange
and HMR, because clients can enable live reloading and hot reloading.Thanks for your point, I tested competition, HMR first and Live Reload first, every are not good, just worked.
Is it possible to bundle once for Live Reload and HMR? or more common works to reduce bundle time? I can't handle this topic, I don't know details of how packager/bundler works yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpunion thanks for answering so quickly and for contributing!
Unfortunately no. We reuse much of the intermediate stuff though, but the bundle itself cannot be share as the Live Reload one is a full bundle whereas the HMR one contains only the the code of the modules that have changed + the new modules if any.
I'm not sure if it worth supporting this use case, feel like it's an edge case but I might be wrong. If it's an edge case we need to make sure it doesn't make the HMR experience worse and that the additional complexity that it adds worth it.
I think it would be very useful to create a product pains and ask around if this is something the community would like the support for :). If there's broad interest we could work on improving this pull request to avoid a hit on performance. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinbigio Thanks for your explain clearly. I think if HMR works fine and can replace Live Reload, we no longer need Live Reload. Yes, it seems an edge case.
Thanks again.