Skip to content

Commit 64b63f4

Browse files
author
Brian Vaughn
committed
Updated Rollup bundle for test-utils
* Moved test-utils into react-dom package * Added test-utils to package.json 'files' list * Added ReactTestUtilsFBEntry module (though it doesn't really do anything at the moment) * Replaced ReactDOM references with react-dom to avoid duplicating code
1 parent aa88a15 commit 64b63f4

File tree

10 files changed

+61
-47
lines changed

10 files changed

+61
-47
lines changed

packages/react-dom/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"README.md",
2828
"index.js",
2929
"server.js",
30+
"test-utils.js",
3031
"cjs/",
3132
"umd/"
3233
],

packages/react-dom/test-utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV !== 'production') {
4+
module.exports = require('./cjs/test-utils.development.js');
5+
}

scripts/rollup/bundles.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const bundles = [
125125
},
126126
{
127127
babelOpts: babelOptsReact,
128-
bundleTypes: [NODE_DEV],
128+
bundleTypes: [FB_DEV, NODE_DEV],
129129
config: {
130130
destDir: 'build/',
131131
globals: {
@@ -135,14 +135,20 @@ const bundles = [
135135
sourceMap: false,
136136
},
137137
entry: 'src/test/ReactTestUtils.js',
138-
externals: ['prop-types', 'prop-types/checkPropTypes', 'react'],
138+
externals: [
139+
'prop-types',
140+
'prop-types/checkPropTypes',
141+
'react',
142+
'react-dom',
143+
'react-dom/test-utils',
144+
],
145+
fbEntry: 'src/fb/ReactTestUtilsFBEntry.js',
139146
hasteName: 'ReactTestUtils',
140147
isRenderer: false,
141-
label: 'react-test-utils',
148+
label: 'test-utils',
142149
manglePropertiesOnProd: false,
143-
name: 'react-test-utils',
150+
name: 'react-dom/test-utils',
144151
paths: [
145-
'src/renderers/dom/**/*.js',
146152
'src/renderers/shared/**/*.js',
147153
'src/test/**/*.js', // ReactTestUtils is currently very coupled to DOM.
148154

scripts/rollup/results.json

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
"gzip": 5761
1111
},
1212
"react-dom.development.js (UMD_DEV)": {
13-
"size": 583148,
14-
"gzip": 134526
13+
"size": 583284,
14+
"gzip": 134555
1515
},
1616
"react-dom.production.min.js (UMD_PROD)": {
17-
"size": 120740,
18-
"gzip": 38094
17+
"size": 120793,
18+
"gzip": 38119
1919
},
2020
"react-dom-server.development.js (UMD_DEV)": {
2121
"size": 495516,
@@ -50,28 +50,28 @@
5050
"gzip": 9248
5151
},
5252
"ReactDOMStack-dev.js (FB_DEV)": {
53-
"size": 522721,
54-
"gzip": 124723
53+
"size": 492312,
54+
"gzip": 117399
5555
},
5656
"ReactDOMStack-prod.js (FB_PROD)": {
57-
"size": 352776,
58-
"gzip": 84675
57+
"size": 352924,
58+
"gzip": 84697
5959
},
6060
"react-dom.development.js (NODE_DEV)": {
61-
"size": 542144,
62-
"gzip": 125150
61+
"size": 542280,
62+
"gzip": 125179
6363
},
6464
"react-dom.production.min.js (NODE_PROD)": {
65-
"size": 116925,
66-
"gzip": 36732
65+
"size": 116978,
66+
"gzip": 36758
6767
},
6868
"ReactDOMFiber-dev.js (FB_DEV)": {
69-
"size": 797189,
70-
"gzip": 184111
69+
"size": 543121,
70+
"gzip": 125573
7171
},
7272
"ReactDOMFiber-prod.js (FB_PROD)": {
73-
"size": 407613,
74-
"gzip": 93586
73+
"size": 407761,
74+
"gzip": 93608
7575
},
7676
"react-dom-server.development.js (NODE_DEV)": {
7777
"size": 445547,
@@ -140,6 +140,14 @@
140140
"react-test-utils.development.js (NODE_DEV)": {
141141
"size": 510240,
142142
"gzip": 122093
143+
},
144+
"react-dom-test-utils.development.js (NODE_DEV)": {
145+
"size": 78532,
146+
"gzip": 19766
147+
},
148+
"ReactTestUtils-dev.js (FB_DEV)": {
149+
"size": 528,
150+
"gzip": 328
143151
}
144152
}
145153
}

src/fb/ReactDOMFBEntry.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ Object.assign(ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
4343

4444
if (__DEV__) {
4545
Object.assign(ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
46-
// ReactPerf and ReactTestUtils currently only work with the DOM renderer
47-
// so we expose them from here, but only in DEV mode.
46+
// ReactPerf currently only works with the DOM renderer
47+
// so we expose it here, but only in DEV mode.
4848
ReactPerf: require('ReactPerf'),
49-
ReactTestUtils: require('ReactTestUtils'),
5049
});
5150
}
5251

src/fb/ReactDOMFiberFBEntry.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,4 @@ Object.assign(
4545
},
4646
);
4747

48-
if (__DEV__) {
49-
Object.assign(
50-
ReactDOMFiber.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
51-
{
52-
// ReactPerf and ReactTestUtils currently only work with the DOM renderer
53-
// so we expose them from here, but only in DEV mode.
54-
ReactTestUtils: require('ReactTestUtils'),
55-
},
56-
);
57-
}
58-
5948
module.exports = ReactDOMFiber;

scripts/rollup/shims/facebook-www/ReactTestUtils.js renamed to src/fb/ReactTestUtilsFBEntry.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
* This source code is licensed under the BSD-style license found in the
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
8-
*
9-
* @providesModule ReactTestUtils
108
*/
119

1210
'use strict';
1311

14-
const {
15-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
16-
} = require('ReactDOM-fb');
12+
var ReactTestUtils = require('react-dom/test-utils');
1713

18-
module.exports = __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactTestUtils;
14+
module.exports = ReactTestUtils;

src/renderers/dom/ReactDOM.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ var ReactDOM = {
4242
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
4343
// For TapEventPlugin which is popular in open source
4444
EventPluginHub: require('EventPluginHub'),
45+
// Used by test-utils
46+
ReactDOMComponentTree,
47+
ReactBrowserEventEmitter: require('ReactBrowserEventEmitter'),
4548
},
4649
};
4750

src/renderers/dom/fiber/ReactDOMFiber.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ var ReactDOM = {
543543
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
544544
// For TapEventPlugin which is popular in open source
545545
EventPluginHub: require('EventPluginHub'),
546+
// Used by test-utils
547+
ReactDOMComponentTree,
548+
ReactBrowserEventEmitter,
546549
},
547550
};
548551

src/test/ReactTestUtils.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ var EventPluginRegistry = require('EventPluginRegistry');
1717
var EventPropagators = require('EventPropagators');
1818
var React = require('react');
1919
var ReactControlledComponent = require('ReactControlledComponent');
20-
var ReactDOM = require('ReactDOM');
21-
var ReactDOMComponentTree = require('ReactDOMComponentTree');
22-
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
20+
var ReactDOM = require('react-dom');
2321
var ReactFiberTreeReflection = require('ReactFiberTreeReflection');
2422
var ReactInstanceMap = require('ReactInstanceMap');
2523
var ReactTypeOfWork = require('ReactTypeOfWork');
2624
var ReactGenericBatching = require('ReactGenericBatching');
2725
var SyntheticEvent = require('SyntheticEvent');
28-
var ReactShallowRenderer = require('ReactShallowRenderer');
2926

30-
var findDOMNode = require('findDOMNode');
3127
var invariant = require('fbjs/lib/invariant');
3228

29+
var {findDOMNode} = ReactDOM;
30+
var {
31+
ReactDOMComponentTree,
32+
ReactBrowserEventEmitter,
33+
} = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
34+
3335
var topLevelTypes = EventConstants.topLevelTypes;
3436
var {
3537
ClassComponent,
@@ -403,9 +405,11 @@ var ReactTestUtils = {
403405
};
404406
},
405407

408+
/**
409+
* TODO (bvaughn) Re-add with an export to react-test-renderer/shallow and a message
406410
createRenderer: function() {
407-
return new ReactShallowRenderer();
408411
},
412+
*/
409413

410414
Simulate: null,
411415
SimulateNative: {},

0 commit comments

Comments
 (0)