mirror of
https://github.com/facebook/react.git
synced 2026-02-25 23:45:10 +00:00
* [react-native] Use path-based imports instead of Haste for the RN renderer To move React Native to standard path-based imports instead of Haste, the RN renderer that is generated from the code in this repo needs to use path-based imports as well since the generated code is vendored by RN. This commit makes it so the interface between the generated renderers and RN does not rely on Haste and instead uses a private interface explicitly defined by RN. This inverts control of the abstraction so that RN decides the internals to export rather than React deciding what to import. On RN's side, a new module named `react-native/Libraries/ReactPrivate/ReactNativePrivateInterface` explicitly exports the modules used by the renderers in this repo. (There is also a private module for InitializeCore so that we can import it just for the side effects.) On React's side, the various renderer modules access RN internals through the explicit private interface. The Rollup configuration becomes slimmer since the only external package is now `react-native`, and the individual modules are instead listed out in `ReactNativePrivateInterface`. Task description: https://github.com/facebook/react-native/issues/24770 Sister RN PR (needs to land before this one): https://github.com/facebook/react-native/pull/24782 Test Plan: Ran unit tests and Flow in this repo. Generated the renderers and manually copied them over to the RN repo. Ran the RN tests and launched the RNTester app. * Access natively defined "nativeFabricUIManager" instead of importing it Some places in the Fabric renderers access `nativeFabricUIManager` (a natively defined global) instead of importing UIManager. While this is coupling across repos that depends on the timing of events, it is necessary until we have a way to defer top-level imports to run after `nativeFabricUIManager` is defined. So for consistency we use `nativeFabricUIManager` everywhere (see the comment in https://github.com/facebook/react/pull/15604#pullrequestreview-236842223 for more context).
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
/**
|
|
* Make sure essential globals are available and are patched correctly. Please don't remove this
|
|
* line. Bundles created by react-packager `require` it before executing any application code. This
|
|
* ensures it exists in the dependency graph and can be `require`d.
|
|
* TODO: require this in packager, not in React #10932517
|
|
*/
|
|
// Module provided by RN:
|
|
import 'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore';
|
|
|
|
import {injection as EventPluginHubInjection} from 'events/EventPluginHub';
|
|
import ResponderEventPlugin from 'events/ResponderEventPlugin';
|
|
|
|
import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin';
|
|
import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder';
|
|
|
|
/**
|
|
* Inject module for resolving DOM hierarchy and plugin ordering.
|
|
*/
|
|
EventPluginHubInjection.injectEventPluginOrder(ReactNativeEventPluginOrder);
|
|
|
|
/**
|
|
* Some important event plugins included by default (without having to require
|
|
* them).
|
|
*/
|
|
EventPluginHubInjection.injectEventPluginsByName({
|
|
ResponderEventPlugin: ResponderEventPlugin,
|
|
ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin,
|
|
});
|