You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add unstable_transformResultKey and prune unmodified modules from deltas
Summary:
`Graph.traverseDependencies`, at the core of delta calculation and therefore Fast Refresh and incremental builds, relies on being given a list of modified file paths, and derives a graph delta from them. Currently, if a path corresponds to a module in a given graph, that module will be returned as a "modified" module, serialised, and sent to the client for execution.
This diff introduces modified module pruning, by
a) being more selective about when we regard a module as *potentially* modified during traversal, and then
b) by actually diffing the modules as a final pass before returning a delta.
We do this by storing the transformer's cache key as a "`transformResultKey`", diffing that, and also diffing dependencies and inverse dependencies to account for resolution changes.
## Package exports and symlinks
Because we don't *yet* have smart-enough incremental invalidation of resolutions, we have to invalidate the whole of every graph for any symlink or `package.json#exports` change. We implement this by calling `Graph.traverseDependencies` with *every* path in the graph. Currently, without pruning unmodified modules, this results in enormous deltas of hundreds of nodes.
With pruning, although we must still re-traverse and re-resolve everything, we can avoid sending anything to the client unless there are any actual changes (and then, only send the minimum), and consequently do much less injection/execution on the client.
This results in correct Fast Refresh of symlink and `package.json#exports` changes in subsecond time, and (IMO) unblocks symlinks-by-default.
```
- **[Performance]**: Prune unmodified modules from delta updates before sending them to the client
```
Reviewed By: Andjeliko
Differential Revision: D45691844
fbshipit-source-id: df09a3ec9016f691ef0bfaea5a723a9ec57d9d79
0 commit comments