Use deep require instead of Haste for NativeComponentRegistry

Summary:
Changelog: [Internal]

Some environments that use codegen don't have Haste enabled, breaking the `require('NativeComponentRegistry')` call in generated view configs. Here we change it to reference an explicit path relative to `react-native`.

Reviewed By: JoshuaGross

Differential Revision: D31166063

fbshipit-source-id: cebc23d0d95b5cde76d0f8473eabc03ca82a862e
This commit is contained in:
Moti Zilberman
2021-09-27 13:45:44 -07:00
committed by Facebook GitHub Bot
parent 6ea3df0507
commit 268efb1022
3 changed files with 30 additions and 30 deletions
@@ -22,7 +22,7 @@ interface NativeCommands {
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,
}
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
const {
dispatchCommand
@@ -84,7 +84,7 @@ interface NativeCommands {
+scrollTo: (viewRef: React.ElementRef<NativeType>, y: Int32, animated: boolean) => void,
}
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
const {
dispatchCommand
@@ -177,7 +177,7 @@ function buildViewConfig(
switch (extendProps.knownTypeName) {
case 'ReactNativeCoreViewProps':
imports.add(
"const NativeComponentRegistry = require('NativeComponentRegistry');",
"const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');",
);
return;
@@ -16,7 +16,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ArrayPropsNativeComponent';
@@ -61,7 +61,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ArrayPropsNativeComponent';
@@ -92,7 +92,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'BooleanPropNativeComponent';
@@ -123,7 +123,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ColorPropNativeComponent';
@@ -156,7 +156,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\");
let nativeComponentName = 'CommandNativeComponent';
@@ -195,7 +195,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
const {dispatchCommand} = require(\\"react-native/Libraries/Renderer/shims/ReactNative\\");
let nativeComponentName = 'CommandNativeComponent';
@@ -237,7 +237,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'DoublePropNativeComponent';
@@ -273,7 +273,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'EventsNestedObjectNativeComponent';
@@ -314,7 +314,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'EventsNativeComponent';
@@ -375,7 +375,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'RCTInterfaceOnlyComponent';
@@ -433,7 +433,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ExcludedAndroidComponent';
@@ -461,7 +461,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ExcludedAndroidIosComponent';
@@ -489,7 +489,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'FloatPropNativeComponent';
@@ -525,7 +525,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ImagePropNativeComponent';
@@ -558,7 +558,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'InsetsPropNativeComponent';
@@ -591,7 +591,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'Int32EnumPropsNativeComponent';
@@ -622,7 +622,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'IntegerPropNativeComponent';
@@ -655,7 +655,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'RCTInterfaceOnlyComponent';
@@ -696,7 +696,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ImageColorPropNativeComponent';
@@ -741,7 +741,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'NoPropsNoEventsComponent';
@@ -769,7 +769,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ObjectProps';
@@ -800,7 +800,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'PointPropNativeComponent';
@@ -833,7 +833,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'StringEnumPropsNativeComponent';
@@ -864,7 +864,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'StringPropComponent';
@@ -896,7 +896,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'MultiFile1NativeComponent';
@@ -937,7 +937,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'MultiComponent1NativeComponent';
@@ -978,7 +978,7 @@ Map {
'use strict';
const NativeComponentRegistry = require('NativeComponentRegistry');
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
const {UIManager} = require(\\"react-native\\")
let nativeComponentName = 'NativeComponentName';