mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
[Flare] Add RN build step for ReactTypes (#15926)
This commit is contained in:
@@ -13,6 +13,7 @@ import type {
|
||||
MeasureOnSuccessCallback,
|
||||
NativeMethodsMixinType,
|
||||
ReactNativeBaseComponentViewConfig,
|
||||
ReactNativeEventResponder,
|
||||
} from './ReactNativeTypes';
|
||||
import type {ReactEventComponentInstance} from 'shared/ReactTypes';
|
||||
|
||||
@@ -76,7 +77,7 @@ export type UpdatePayload = Object;
|
||||
|
||||
export type TimeoutHandle = TimeoutID;
|
||||
export type NoTimeout = -1;
|
||||
export type EventResponder = any;
|
||||
export type EventResponder = ReactNativeEventResponder;
|
||||
|
||||
// TODO: Remove this conditional once all changes have propagated.
|
||||
if (registerEventHandler) {
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type {ReactNativeBaseComponentViewConfig} from './ReactNativeTypes';
|
||||
import type {
|
||||
ReactNativeBaseComponentViewConfig,
|
||||
ReactNativeEventResponder,
|
||||
} from './ReactNativeTypes';
|
||||
import type {ReactEventComponentInstance} from 'shared/ReactTypes';
|
||||
|
||||
import invariant from 'shared/invariant';
|
||||
@@ -48,7 +51,7 @@ export type ChildSet = void; // Unused
|
||||
|
||||
export type TimeoutHandle = TimeoutID;
|
||||
export type NoTimeout = -1;
|
||||
export type EventResponder = any;
|
||||
export type EventResponder = ReactNativeEventResponder;
|
||||
|
||||
const UPDATE_SIGNAL = {};
|
||||
if (__DEV__) {
|
||||
|
||||
@@ -157,3 +157,6 @@ export type ReactFabricType = {
|
||||
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: SecretInternalsFabricType,
|
||||
};
|
||||
|
||||
// TODO will be addressed with upcoming React Flare support
|
||||
export type ReactNativeEventResponder = any;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// NOTE: this line is changed in the RN build, see: copyRNShims in packaging.js
|
||||
import type {EventResponder} from 'react-reconciler/src/ReactFiberHostConfig';
|
||||
|
||||
export type ReactNode =
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const {existsSync, readdirSync, unlinkSync} = require('fs');
|
||||
const {
|
||||
existsSync,
|
||||
readdirSync,
|
||||
unlinkSync,
|
||||
readFileSync,
|
||||
writeFileSync,
|
||||
} = require('fs');
|
||||
const Bundles = require('./bundles');
|
||||
const {
|
||||
asyncCopyTo,
|
||||
@@ -87,18 +93,22 @@ async function copyWWWShims() {
|
||||
}
|
||||
|
||||
async function copyRNShims() {
|
||||
const reactTypesBuildTarget = 'build/react-native/shims/ReactTypes.js';
|
||||
await Promise.all([
|
||||
// React Native
|
||||
asyncCopyTo(`${__dirname}/shims/react-native`, 'build/react-native/shims'),
|
||||
asyncCopyTo(
|
||||
require.resolve('shared/ReactTypes.js'),
|
||||
'build/react-native/shims/ReactTypes.js'
|
||||
),
|
||||
asyncCopyTo(require.resolve('shared/ReactTypes.js'), reactTypesBuildTarget),
|
||||
asyncCopyTo(
|
||||
require.resolve('react-native-renderer/src/ReactNativeTypes.js'),
|
||||
'build/react-native/shims/ReactNativeTypes.js'
|
||||
),
|
||||
]);
|
||||
// Modify the EventResponder type in ReactTypes
|
||||
const reactTypesSource = readFileSync(reactTypesBuildTarget, 'utf8');
|
||||
const original = `import type {EventResponder} from 'react-reconciler/src/ReactFiberHostConfig';`;
|
||||
const changeTo = `import type {ReactNativeEventResponder as EventResponder} from './ReactNativeTypes';`;
|
||||
const modifiedSource = reactTypesSource.replace(original, changeTo);
|
||||
writeFileSync(reactTypesBuildTarget, modifiedSource);
|
||||
}
|
||||
|
||||
async function copyAllShims() {
|
||||
|
||||
Reference in New Issue
Block a user