Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve flexibility for multiple versions of react-native-macos
Summary: The initial approach to resolving react-native-macos core JS modules from either `//xplat/js/react-native-github` or `//third-party/microsoft-fork-of-react-native` left the monorepo in a state where any JS folder that supported `macos` was limited to APIs available in React Native v0.71. This is not sufficient, as apps that upgrade to the latest version of react-native-macos also likely want to start using the latest React and React Native features. To circumvent this limitation, we're minting a new platform moniker, `macos_legacy`. In general though, this platform moniker should not be used as a JS platform override extension (with a minor exception described below). Instead, this `macos_legacy` extension uses Metro `sourceExts` configuration to allow resolution of `*.macos.js` files. The exception to this rule is for haste resolved modules. Metro today does not have sufficient affordance to override the configured platform moniker from a context resolver override. Rather than add such capabilities to Metro for what we expect to be a short-lived feature in our configuration of fb-metro, we add `*.macos_legacy.js` platform overrides for a handful of haste-resolved modules. Specifically: - xplat:DEPRECATED_FBTouchableHighlight - xplat:GreenhouseAsyncStorage - xplat:Shimmer - xplat:WebView - xplat:ReactNativePrivateAPI - socialvr:L10nAPI The remaining changes do the following: 1. Set up a BUCK config setting for apps that use `-c user.rn_macos` 2. Wires up the config setting in buck2 js_library platform moniker resolution to match to `macos_legacy` 3. Adds the new (temporary) platform moniker to fb-config/haste-impl and exclude from flow checks (similar to existing flow check suppression for *.macos.js). 4. Partially back out the previous hacks used to allow multi-version targeting of react-native-macos (D67049837 and D67161193). 5. Add logic to fb-config/metro to inject *.macos sourceExts when `macos_legacy` is used 6. Adds `macos_legacy` to fb-config/dependency-analysis to any `PlatformsByPrefix` entry that previously allowed `macos`. 7. Disables `inlinePlatform` transform option when target platform is `macos_legacy`, or, in the case of metro BUCK, when `-c user.rn_macos` config setting is matched. 8. Fixes the metro-buck-transform-worker to accommodate mismatched platform and file monikers. 9. Makes the default platform moniker for //third-party/microsoft-fork-of-react-native `macos_legacy` in dev builds. 10. Updates various generated config files from `js1 build buckfiles`. Reviewed By: sbuggay Differential Revision: D68246115 fbshipit-source-id: 6cfe329114c4c401ac85cbaaf30eea4401f59ade
- Loading branch information