diff --git a/src/isomorphic/classic/types/checkReactTypeSpec.js b/src/isomorphic/classic/types/checkReactTypeSpec.js index 3b119b395fea2..54978ee0d2bee 100644 --- a/src/isomorphic/classic/types/checkReactTypeSpec.js +++ b/src/isomorphic/classic/types/checkReactTypeSpec.js @@ -11,7 +11,6 @@ 'use strict'; -var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool'); var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames'); var invariant = require('invariant'); @@ -72,10 +71,13 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element, var componentStackInfo = ''; - if (debugID !== null) { - componentStackInfo = ReactComponentTreeDevtool.getStackAddendumByID(debugID); - } else if (element !== null) { - componentStackInfo = ReactComponentTreeDevtool.getCurrentStackAddendum(element); + if (__DEV__) { + var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool'); + if (debugID !== null) { + componentStackInfo = ReactComponentTreeDevtool.getStackAddendumByID(debugID); + } else if (element !== null) { + componentStackInfo = ReactComponentTreeDevtool.getCurrentStackAddendum(element); + } } warning( diff --git a/src/renderers/dom/shared/ReactDOMDebugTool.js b/src/renderers/dom/shared/ReactDOMDebugTool.js index 784de948fa90c..a1c1124b5b30c 100644 --- a/src/renderers/dom/shared/ReactDOMDebugTool.js +++ b/src/renderers/dom/shared/ReactDOMDebugTool.js @@ -11,8 +11,6 @@ 'use strict'; -var ReactDOMNullInputValuePropDevtool = require('ReactDOMNullInputValuePropDevtool'); -var ReactDOMUnknownPropertyDevtool = require('ReactDOMUnknownPropertyDevtool'); var ReactDebugTool = require('ReactDebugTool'); var warning = require('warning'); @@ -68,7 +66,11 @@ var ReactDOMDebugTool = { }, }; -ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool); -ReactDOMDebugTool.addDevtool(ReactDOMNullInputValuePropDevtool); +if (__DEV__) { + var ReactDOMNullInputValuePropDevtool = require('ReactDOMNullInputValuePropDevtool'); + var ReactDOMUnknownPropertyDevtool = require('ReactDOMUnknownPropertyDevtool'); + ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool); + ReactDOMDebugTool.addDevtool(ReactDOMNullInputValuePropDevtool); +} module.exports = ReactDOMDebugTool; diff --git a/src/renderers/shared/stack/reconciler/ReactChildReconciler.js b/src/renderers/shared/stack/reconciler/ReactChildReconciler.js index de97da800fa2b..2e7479bd0d940 100644 --- a/src/renderers/shared/stack/reconciler/ReactChildReconciler.js +++ b/src/renderers/shared/stack/reconciler/ReactChildReconciler.js @@ -13,7 +13,6 @@ var ReactReconciler = require('ReactReconciler'); -var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool'); var instantiateReactComponent = require('instantiateReactComponent'); var KeyEscapeUtils = require('KeyEscapeUtils'); var shouldUpdateReactComponent = require('shouldUpdateReactComponent'); @@ -24,6 +23,7 @@ function instantiateChild(childInstances, child, name, selfDebugID) { // We found a component instance. var keyUnique = (childInstances[name] === undefined); if (__DEV__) { + var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool'); warning( keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + diff --git a/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js b/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js index 034d839b0fc0c..50a1a01e208ff 100644 --- a/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js +++ b/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js @@ -278,6 +278,12 @@ function testPropsSequence(sequence) { describe('ReactMultiChildReconcile', function() { beforeEach(function() { jest.resetModuleRegistry(); + + React = require('React'); + ReactDOM = require('ReactDOM'); + ReactDOMComponentTree = require('ReactDOMComponentTree'); + ReactInstanceMap = require('ReactInstanceMap'); + mapObject = require('mapObject'); }); it('should reset internal state if removed then readded', function() { diff --git a/src/renderers/shared/stack/reconciler/__tests__/refs-test.js b/src/renderers/shared/stack/reconciler/__tests__/refs-test.js index 6811cfe4dc316..db7f5ad57ef5a 100644 --- a/src/renderers/shared/stack/reconciler/__tests__/refs-test.js +++ b/src/renderers/shared/stack/reconciler/__tests__/refs-test.js @@ -116,6 +116,10 @@ var expectClickLogsLengthToBe = function(instance, length) { describe('reactiverefs', function() { beforeEach(function() { jest.resetModuleRegistry(); + + React = require('React'); + ReactTestUtils = require('ReactTestUtils'); + reactComponentExpect = require('reactComponentExpect'); }); /** @@ -159,6 +163,10 @@ describe('reactiverefs', function() { describe('ref swapping', function() { beforeEach(function() { jest.resetModuleRegistry(); + + React = require('React'); + ReactTestUtils = require('ReactTestUtils'); + reactComponentExpect = require('reactComponentExpect'); }); var RefHopsAround = React.createClass({ @@ -275,4 +283,3 @@ describe('ref swapping', function() { __DEV__ = originalDev; }); }); - diff --git a/src/shared/utils/flattenChildren.js b/src/shared/utils/flattenChildren.js index afb12d5a46556..cf0ea09ded898 100644 --- a/src/shared/utils/flattenChildren.js +++ b/src/shared/utils/flattenChildren.js @@ -12,7 +12,6 @@ 'use strict'; -var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool'); var KeyEscapeUtils = require('KeyEscapeUtils'); var traverseAllChildren = require('traverseAllChildren'); var warning = require('warning'); @@ -34,6 +33,7 @@ function flattenSingleChildIntoContext( const result = traverseContext; const keyUnique = (result[name] === undefined); if (__DEV__) { + var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool'); warning( keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' +