refactor: use Metro HMR socket to listen for changes #65
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.
Fixes #60
This resolves an issue where
.getBundler().getDelta()
actually resets the information before the HMR server loads the delta information. It results in the clients not being updated.The new system uses the
<metroUrl>/hot
to listen for any changes in the web UI. Unfortunately, Metro's HMR system is very limited, and it only provides a module ID. This means that we can't match per-path anymore, as resolving a module ID to a module path is impossible.When a change is detected, it will check if we can auto-update. If so, we'll ask Atlas to reload the data through all bundles
serializerOptions.sourceUrl
. If that doesn't exist, e.g. forserver
bundles, we can't update the data.Preferably, we'd be able to hook into Metro better to listen for changes on the server and update automatically, without the Atlas webui being open. But, that's not possible atm without using private APIs.