Skip to content

metro-file-map: Remove micromatch - #2000

Draft
robhogan wants to merge 1 commit into
mainfrom
pr1999
Draft

robhogan wants to merge 1 commit into
mainfrom
pr1999

Conversation

@robhogan

Copy link
Copy Markdown
Collaborator

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:

const ext = path.extname(name).substr(1);
if (!isSymbolicLink && !exts.has(ext)) {

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.

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.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant