Conversation
The watcher backends filter change events by matching each relative path against globs with `micromatch`. Those globs aren't configurable - Metro builds them from `extensions`, plus `**/package.json` and the health check file prefix - so all micromatch ever checks is an extension, a file name or a prefix. This replaces the watchers' `globs` option with a `fileFilter` of extensions, file names and file name prefixes, checked with `Set` lookups and `startsWith`. Extensions are compared using `path.extname`, the same as the Node crawler: https://github.com/react/metro/blob/13604e0207e02c6aed7fbff97af439ed2df5fd1f/packages/metro-file-map/src/crawlers/node/index.js#L78-L79 It also removes the watchers' `dot` option, which Metro always set to `true`, and the unused `Glob` type. With that, `micromatch` is no longer a dependency of `metro-file-map`. The watcher backends are only reachable through `metro-file-map/private/*`, and Expo uses neither them nor the removed types. Changelog: Internal Test plan: New unit test for the file filter. `integration-test.js` drives each watcher backend against a real temporary tree with an extension, a file name and a prefix in the filter, so it exercises this directly.
This branch has not been deployed
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
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.
The watcher backends filter change events by matching each relative path against globs with
micromatch. Those globs aren't configurable - Metro builds them fromextensions, plus**/package.jsonand the health check file prefix - so all micromatch ever checks is an extension, a file name or a prefix.This replaces the watchers'
globsoption with afileFilterof extensions, file names and file name prefixes, checked withSetlookups andstartsWith. Extensions are compared usingpath.extname, the same as the Node crawler:metro/packages/metro-file-map/src/crawlers/node/index.js
Lines 78 to 79 in 13604e0
It also removes the watchers'
dotoption, which Metro always set totrue, and the unusedGlobtype. With that,micromatchis no longer a dependency ofmetro-file-map. The watcher backends are only reachable throughmetro-file-map/private/*, and Expo uses neither them nor the removed types.Changelog: Internal
Test plan:
New unit test for the file filter.
integration-test.jsdrives each watcher backend against a real temporary tree with an extension, a file name and a prefix in the filter, so it exercises this directly.