Skip to content

Commit 59445a6

Browse files
committed
Hack around to fix RN bundle
1 parent 245c082 commit 59445a6

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

scripts/rollup/bundles.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ const bundles = [
227227
},
228228
entry: 'src/renderers/native/ReactNative.js',
229229
externals: [
230+
'ExceptionsManager',
230231
'InitializeCore',
231232
'RCTEventEmitter',
232233
'UIManager',
234+
'View',
233235
'deepDiffer',
234236
'flattenStyle',
235237
'TextInputState',

src/renderers/native/NativeMethodsMixin.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ var findNodeHandle = require('findNodeHandle');
2121

2222
var ReactNative;
2323

24-
// TODO: figure this out when we work on flat bundles in RN.
25-
// This might not be needed after all.
24+
// Works around a circular dependency in flat bundle.
2625
function injectReactNative(RN: $FlowFixMe) {
2726
ReactNative = RN;
2827
}
@@ -159,7 +158,6 @@ var NativeMethodsMixin = {
159158
TextInputState.blurTextInput(ReactNative.findNodeHandle(this));
160159
},
161160

162-
// Temporary hack to avoid a circular dependency
163161
__injectReactNative: injectReactNative,
164162
};
165163

src/renderers/native/ReactNative.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212

1313
var ReactNativeFeatureFlags = require('ReactNativeFeatureFlags');
1414
var NativeMethodsMixin = require('NativeMethodsMixin');
15+
var takeSnapshot = require('takeSnapshot');
1516

1617
var ReactNative = ReactNativeFeatureFlags.useFiber
1718
? require('ReactNativeFiber')
1819
: require('ReactNativeStack');
1920

21+
// Work around circular dependencies
2022
NativeMethodsMixin.__injectReactNative(ReactNative);
23+
takeSnapshot.__injectReactNative(ReactNative);
2124

2225
ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
2326
createReactNativeComponentClass: require('createReactNativeComponentClass'),

src/renderers/native/takeSnapshot.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
*/
1212
'use strict';
1313

14-
var ReactNative = require('ReactNative');
1514
var UIManager = require('UIManager');
1615

16+
var ReactNative;
17+
18+
// Works around a circular dependency in flat bundle.
19+
function injectReactNative(RN: $FlowFixMe) {
20+
ReactNative = RN;
21+
}
22+
1723
import type {Element} from 'React';
1824

1925
/**
@@ -51,4 +57,6 @@ function takeSnapshot(
5157
return UIManager.__takeSnapshot(view, options);
5258
}
5359

60+
takeSnapshot.__injectReactNative = injectReactNative;
61+
5462
module.exports = takeSnapshot;

0 commit comments

Comments
 (0)