@samitouri / QOS-React / commits / 8fe6b5fb46

Inline dev-only requires (#7188)

* Inline dev-only requires This reduces the production bundled build size. * Use new references after resetting module registry in tests This fixes the tests which were broken due to inlining some requires.

Dan Abramov committed Jul 5, 2016 at 18:20 UTC 8fe6b5fb46ab865381bf0485a0a285d820c6d278
6 files changed +29 -12
src/isomorphic/classic/types/checkReactTypeSpec.js
+7 -5
@@ -11,7 +11,6 @@
11
12 'use strict';
13
14 -var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
14 var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames');
15
16 var invariant = require('invariant');
@@ -72,10 +71,13 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
71
72 var componentStackInfo = '';
73
75 - if (debugID !== null) {
76 - componentStackInfo = ReactComponentTreeDevtool.getStackAddendumByID(debugID);
77 - } else if (element !== null) {
78 - componentStackInfo = ReactComponentTreeDevtool.getCurrentStackAddendum(element);
74 + if (__DEV__) {
75 + var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
76 + if (debugID !== null) {
77 + componentStackInfo = ReactComponentTreeDevtool.getStackAddendumByID(debugID);
78 + } else if (element !== null) {
79 + componentStackInfo = ReactComponentTreeDevtool.getCurrentStackAddendum(element);
80 + }
81 }
82
83 warning(
src/renderers/dom/shared/ReactDOMDebugTool.js
+6 -4
@@ -11,8 +11,6 @@
11
12 'use strict';
13
14 -var ReactDOMNullInputValuePropDevtool = require('ReactDOMNullInputValuePropDevtool');
15 -var ReactDOMUnknownPropertyDevtool = require('ReactDOMUnknownPropertyDevtool');
14 var ReactDebugTool = require('ReactDebugTool');
15
16 var warning = require('warning');
@@ -68,7 +66,11 @@ var ReactDOMDebugTool = {
66 },
67 };
68
71 -ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool);
72 -ReactDOMDebugTool.addDevtool(ReactDOMNullInputValuePropDevtool);
69 +if (__DEV__) {
70 + var ReactDOMNullInputValuePropDevtool = require('ReactDOMNullInputValuePropDevtool');
71 + var ReactDOMUnknownPropertyDevtool = require('ReactDOMUnknownPropertyDevtool');
72 + ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool);
73 + ReactDOMDebugTool.addDevtool(ReactDOMNullInputValuePropDevtool);
74 +}
75
76 module.exports = ReactDOMDebugTool;
src/renderers/shared/stack/reconciler/ReactChildReconciler.js
+1 -1
@@ -13,7 +13,6 @@
13
14 var ReactReconciler = require('ReactReconciler');
15
16 -var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
16 var instantiateReactComponent = require('instantiateReactComponent');
17 var KeyEscapeUtils = require('KeyEscapeUtils');
18 var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
@@ -24,6 +23,7 @@ function instantiateChild(childInstances, child, name, selfDebugID) {
23 // We found a component instance.
24 var keyUnique = (childInstances[name] === undefined);
25 if (__DEV__) {
26 + var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
27 warning(
28 keyUnique,
29 'flattenChildren(...): Encountered two children with the same key, ' +
src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildReconcile-test.js
+6
@@ -278,6 +278,12 @@ function testPropsSequence(sequence) {
278 describe('ReactMultiChildReconcile', function() {
279 beforeEach(function() {
280 jest.resetModuleRegistry();
281 +
282 + React = require('React');
283 + ReactDOM = require('ReactDOM');
284 + ReactDOMComponentTree = require('ReactDOMComponentTree');
285 + ReactInstanceMap = require('ReactInstanceMap');
286 + mapObject = require('mapObject');
287 });
288
289 it('should reset internal state if removed then readded', function() {
src/renderers/shared/stack/reconciler/__tests__/refs-test.js
+8 -1
@@ -116,6 +116,10 @@ var expectClickLogsLengthToBe = function(instance, length) {
116 describe('reactiverefs', function() {
117 beforeEach(function() {
118 jest.resetModuleRegistry();
119 +
120 + React = require('React');
121 + ReactTestUtils = require('ReactTestUtils');
122 + reactComponentExpect = require('reactComponentExpect');
123 });
124
125 /**
@@ -159,6 +163,10 @@ describe('reactiverefs', function() {
163 describe('ref swapping', function() {
164 beforeEach(function() {
165 jest.resetModuleRegistry();
166 +
167 + React = require('React');
168 + ReactTestUtils = require('ReactTestUtils');
169 + reactComponentExpect = require('reactComponentExpect');
170 });
171
172 var RefHopsAround = React.createClass({
@@ -275,4 +283,3 @@ describe('ref swapping', function() {
283 __DEV__ = originalDev;
284 });
285 });
278 -
src/shared/utils/flattenChildren.js
+1 -1
@@ -12,7 +12,6 @@
12
13 'use strict';
14
15 -var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
15 var KeyEscapeUtils = require('KeyEscapeUtils');
16 var traverseAllChildren = require('traverseAllChildren');
17 var warning = require('warning');
@@ -34,6 +33,7 @@ function flattenSingleChildIntoContext(
33 const result = traverseContext;
34 const keyUnique = (result[name] === undefined);
35 if (__DEV__) {
36 + var ReactComponentTreeDevtool = require('ReactComponentTreeDevtool');
37 warning(
38 keyUnique,
39 'flattenChildren(...): Encountered two children with the same key, ' +