Skip to content
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

Reduce duplication, tighten types in Watcher backends, remove anymatch dependency #1407

Closed
wants to merge 1 commit into from

Conversation

robhogan
Copy link
Contributor

Differential Revision: D67259981

@facebook-github-bot facebook-github-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 Dec 16, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67259981

facebook-github-bot pushed a commit that referenced this pull request Dec 18, 2024
…cy (#1407)

Summary: Pull Request resolved: #1407

Differential Revision: D67259981
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67259981

…cy (#1407)

Summary:
We currently use the [`anymatch`](https://www.npmjs.com/package/anymatch) dependency to evaluate ignore patterns in watcher backends. `anymatch` handles various input types including globs and arrays of globs/regexps

However, since D67285745, it's become clear that the `ignored` param is only ever a `?RegExp`, so we hardly use any of `anymatch` and can simply `test()` paths, and remove the dependency.

One subtlety to note that this change makes explicit, is that `anymatch` converts all input paths to posix separators before testing against the input `RegExp` (see block comment). We do the same in this diff so that the change is behaviour-preserving - however, this isn't a convention in Metro and should be revisited (maybe in a breaking change).

Note that we don't need to handle other kinds of path normalisation (like `anymatch` does with [`normalize-path`](https://www.npmjs.com/package/normalize-path)) because watcher backends must already emit normal paths, with no trailing separators. 

Changelog: Internal


Differential Revision: D67259981
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67259981

facebook-github-bot pushed a commit that referenced this pull request Dec 21, 2024
…cy (#1407)

Summary:
We currently use the [`anymatch`](https://www.npmjs.com/package/anymatch) dependency to evaluate ignore patterns in watcher backends. `anymatch` handles various input types including globs and arrays of globs/regexps

However, since D67285745, it's become clear that the `ignored` param is only ever a `?RegExp`, so we hardly use any of `anymatch` and can simply `test()` paths, and remove the dependency.

One subtlety to note that this change makes explicit, is that `anymatch` converts all input paths to posix separators before testing against the input `RegExp` (see block comment). We do the same in this diff so that the change is behaviour-preserving - however, this isn't a convention in Metro and should be revisited (maybe in a breaking change).

Note that we don't need to handle other kinds of path normalisation (like `anymatch` does with [`normalize-path`](https://www.npmjs.com/package/normalize-path)) because watcher backends must already emit normal paths, with no trailing separators. 

Changelog: Internal


Reviewed By: hoxyq

Differential Revision: D67259981
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 11c062a.

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. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants