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

Support fsevents watcher on Apple silicon #875

Closed
wants to merge 1 commit into from

Conversation

robhogan
Copy link
Contributor

@robhogan robhogan commented Sep 28, 2022

Summary

If Watchman is unavailable or disabled, we try to fall back to FSEventsWatcher and then to NodeWatcher. FSEventsWatcher is only available on darwin, so we require it in a try/catch and swallow any error.

This was hiding the fact that fsevents was also failing to load on Apple silicon:

 dlopen(/Users/robhogan/gh/metro/node_modules/fsevents/fsevents.node, 0x0001): tried: '/Users/robhogan/gh/metro/node_modules/fsevents/fsevents.node' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))

fsevents@2.3 introduces support for Apple silicon. This updates to that version, and also adds Flow types based on the TypeScript types bundled with fsevents so that Flow check passes on darwin (the Flow error was untyped-import so the existing cannot-resolve-module suppression doesn't work).

Test plan

After:

$ node packages/metro/src/cli serve -c ../dummyproj/metro.config.js

                        ▒▒▓▓▓▓▒▒
                     ▒▓▓▓▒▒░░▒▒▓▓▓▒
                  ▒▓▓▓▓░░░▒▒▒▒░░░▓▓▓▓▒
                 ▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓
                 ▓▓░░░░░▒▓▓▓▓▓▓▒░░░░░▓▓
                 ▓▓░░▓▓▒░░░▒▒░░░▒▓▒░░▓▓
                 ▓▓░░▓▓▓▓▓▒▒▒▒▓▓▓▓▒░░▓▓
                 ▓▓░░▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░▓▓
                 ▓▓▒░░▒▒▓▓▓▓▓▓▓▓▒░░░▒▓▓
                  ▒▓▓▓▒░░░▒▓▓▒░░░▒▓▓▓▒
                     ▒▓▓▓▒░░░░▒▓▓▓▒
                        ▒▒▓▓▓▓▒▒


                Welcome to Metro v0.72.3
              Fast - Scalable - Integrated


  Metro:FSEventsWatcher Watching /Users/robhogan/gh/dummyproj +0ms

@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 Sep 28, 2022
@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

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.

None yet

2 participants