Skip to content

Commit

Permalink
Hack around to fix RN bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Apr 4, 2017
1 parent 245c082 commit 59445a6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ const bundles = [
},
entry: 'src/renderers/native/ReactNative.js',
externals: [
'ExceptionsManager',
'InitializeCore',
'RCTEventEmitter',
'UIManager',
'View',
'deepDiffer',
'flattenStyle',
'TextInputState',
Expand Down
4 changes: 1 addition & 3 deletions src/renderers/native/NativeMethodsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ var findNodeHandle = require('findNodeHandle');

var ReactNative;

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

// Temporary hack to avoid a circular dependency
__injectReactNative: injectReactNative,
};

Expand Down
3 changes: 3 additions & 0 deletions src/renderers/native/ReactNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@

var ReactNativeFeatureFlags = require('ReactNativeFeatureFlags');
var NativeMethodsMixin = require('NativeMethodsMixin');
var takeSnapshot = require('takeSnapshot');

var ReactNative = ReactNativeFeatureFlags.useFiber
? require('ReactNativeFiber')
: require('ReactNativeStack');

// Work around circular dependencies
NativeMethodsMixin.__injectReactNative(ReactNative);
takeSnapshot.__injectReactNative(ReactNative);

ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
createReactNativeComponentClass: require('createReactNativeComponentClass'),
Expand Down
10 changes: 9 additions & 1 deletion src/renderers/native/takeSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@
*/
'use strict';

var ReactNative = require('ReactNative');
var UIManager = require('UIManager');

var ReactNative;

// Works around a circular dependency in flat bundle.
function injectReactNative(RN: $FlowFixMe) {
ReactNative = RN;
}

import type {Element} from 'React';

/**
Expand Down Expand Up @@ -51,4 +57,6 @@ function takeSnapshot(
return UIManager.__takeSnapshot(view, options);
}

takeSnapshot.__injectReactNative = injectReactNative;

module.exports = takeSnapshot;

0 comments on commit 59445a6

Please sign in to comment.