Make ReactDebugCurrentFrame shared state between core and renderers (#9365)
Dan Abramov committed
Apr 7, 2017 at 17:03 UTC
d9fd08df265b51a64b829f4f857b18ebc671879b
5 files changed
+67
-40
scripts/rollup/modules.js
+25
-3
@@ -46,7 +46,9 @@ const fbjsModules = [
46
];
47
48
const devOnlyFilesToStubOut = [
49
+ "'ReactDebugCurrentFrame'",
50
"'ReactComponentTreeHook'",
51
+ "'react/lib/ReactDebugCurrentFrame'",
52
"'react/lib/ReactComponentTreeHook'",
53
"'react-dom/lib/ReactPerf'",
54
"'react-dom/lib/ReactTestUtils'",
@@ -169,9 +171,6 @@ function getInternalModules() {
171
// it doesn't pick them up and assumes they're external
172
return {
173
reactProdInvariant: resolve('./src/shared/utils/reactProdInvariant.js'),
172
- 'react/lib/ReactDebugCurrentFrame': resolve(
173
- './src/isomorphic/classic/element/ReactDebugCurrentFrame.js'
174
- ),
174
};
175
}
176
@@ -277,6 +276,28 @@ function getReactComponentTreeHookModuleAlias(bundleType, isRenderer) {
276
}
277
}
278
279
+// this works almost identically to the ReactCurrentOwner shim above
280
+const shimReactDebugCurrentFrame = resolve(
281
+ './scripts/rollup/shims/rollup/ReactDebugCurrentFrameRollupShim.js'
282
+);
283
+const realReactDebugCurrentFrame = resolve(
284
+ './src/isomorphic/classic/element/ReactDebugCurrentFrame.js'
285
+);
286
+
287
+function getReactDebugCurrentFrameModuleAlias(bundleType, isRenderer) {
288
+ if (isRenderer) {
289
+ return {
290
+ ReactDebugCurrentFrame: shimReactDebugCurrentFrame,
291
+ 'react/lib/ReactDebugCurrentFrame': shimReactDebugCurrentFrame,
292
+ };
293
+ } else {
294
+ return {
295
+ ReactDebugCurrentFrame: realReactDebugCurrentFrame,
296
+ 'react/lib/ReactDebugCurrentFrame': realReactDebugCurrentFrame,
297
+ };
298
+ }
299
+}
300
+
301
const devOnlyModuleStub = `'${resolve('./scripts/rollup/shims/rollup/DevOnlyStubShim.js')}'`;
302
303
function replaceDevOnlyStubbedModules(bundleType) {
@@ -302,6 +323,7 @@ function getAliases(paths, bundleType, isRenderer, extractErrors) {
323
return Object.assign(
324
getReactCurrentOwnerModuleAlias(bundleType, isRenderer),
325
getReactComponentTreeHookModuleAlias(bundleType, isRenderer),
326
+ getReactDebugCurrentFrameModuleAlias(bundleType, isRenderer),
327
createModuleMap(
328
paths,
329
extractErrors && extractErrorCodes(errorCodeOpts),
scripts/rollup/results.json
+35
-35
@@ -1,41 +1,41 @@
1
{
2
- "branch": "master",
2
+ "branch": "debug-frame",
3
"bundleSizes": {
4
"react.development.js (UMD_DEV)": {
5
- "size": 116208,
6
- "gzip": 29564
5
+ "size": 116245,
6
+ "gzip": 29572
7
},
8
"react.production.min.js (UMD_PROD)": {
9
"size": 13719,
10
"gzip": 5080
11
},
12
"react-dom.development.js (UMD_DEV)": {
13
- "size": 564771,
14
- "gzip": 130439
13
+ "size": 563524,
14
+ "gzip": 130148
15
},
16
"react-dom.production.min.js (UMD_PROD)": {
17
"size": 120123,
18
"gzip": 37844
19
},
20
"react-dom-server.development.js (UMD_DEV)": {
21
- "size": 477021,
22
- "gzip": 115494
21
+ "size": 475780,
22
+ "gzip": 115177
23
},
24
"react-dom-server.production.min.js (UMD_PROD)": {
25
"size": 106349,
26
"gzip": 32998
27
},
28
"react-art.development.js (UMD_DEV)": {
29
- "size": 341151,
30
- "gzip": 76261
29
+ "size": 339599,
30
+ "gzip": 75952
31
},
32
"react-art.production.min.js (UMD_PROD)": {
33
"size": 94939,
34
"gzip": 28976
35
},
36
"react.development.js (NODE_DEV)": {
37
- "size": 109222,
38
- "gzip": 27519
37
+ "size": 109259,
38
+ "gzip": 27527
39
},
40
"react.production.min.js (NODE_PROD)": {
41
"size": 12615,
@@ -50,64 +50,64 @@
50
"gzip": 14329
51
},
52
"ReactDOMStack-dev.js (FB_DEV)": {
53
- "size": 523202,
54
- "gzip": 124830
53
+ "size": 521957,
54
+ "gzip": 124586
55
},
56
"ReactDOMStack-prod.js (FB_PROD)": {
57
"size": 351707,
58
"gzip": 84367
59
},
60
"react-dom.development.js (NODE_DEV)": {
61
- "size": 543145,
62
- "gzip": 125402
61
+ "size": 541898,
62
+ "gzip": 125114
63
},
64
"react-dom.production.min.js (NODE_PROD)": {
65
"size": 116802,
66
"gzip": 36707
67
},
68
"ReactDOMFiber-dev.js (FB_DEV)": {
69
- "size": 797617,
70
- "gzip": 184146
69
+ "size": 796380,
70
+ "gzip": 183920
71
},
72
"ReactDOMFiber-prod.js (FB_PROD)": {
73
"size": 407360,
74
"gzip": 93460
75
},
76
"react-dom-server.development.js (NODE_DEV)": {
77
- "size": 446422,
78
- "gzip": 107796
77
+ "size": 445181,
78
+ "gzip": 107467
79
},
80
"react-dom-server.production.min.js (NODE_PROD)": {
81
"size": 101204,
82
"gzip": 31227
83
},
84
"ReactDOMServerStack-dev.js (FB_DEV)": {
85
- "size": 445173,
86
- "gzip": 107652
85
+ "size": 443932,
86
+ "gzip": 107406
87
},
88
"ReactDOMServerStack-prod.js (FB_PROD)": {
89
"size": 332974,
90
"gzip": 80219
91
},
92
"ReactARTStack-dev.js (FB_DEV)": {
93
- "size": 494340,
94
- "gzip": 118840
93
+ "size": 492711,
94
+ "gzip": 118489
95
},
96
"ReactARTStack-prod.js (FB_PROD)": {
97
"size": 365115,
98
"gzip": 87595
99
},
100
"react-art.development.js (NODE_DEV)": {
101
- "size": 266386,
102
- "gzip": 57183
101
+ "size": 264816,
102
+ "gzip": 56881
103
},
104
"react-art.production.min.js (NODE_PROD)": {
105
"size": 56517,
106
"gzip": 17109
107
},
108
"ReactARTFiber-dev.js (FB_DEV)": {
109
- "size": 265561,
110
- "gzip": 57011
109
+ "size": 263991,
110
+ "gzip": 56709
111
},
112
"ReactARTFiber-prod.js (FB_PROD)": {
113
"size": 205194,
@@ -122,20 +122,20 @@
122
"gzip": 84001
123
},
124
"ReactTestRendererFiber-dev.js (FB_DEV)": {
125
- "size": 263452,
126
- "gzip": 55974
125
+ "size": 261900,
126
+ "gzip": 55671
127
},
128
"ReactTestRendererStack-dev.js (FB_DEV)": {
129
- "size": 155222,
130
- "gzip": 35662
129
+ "size": 151142,
130
+ "gzip": 34709
131
},
132
"react-noop-renderer.development.js (NODE_DEV)": {
133
- "size": 255447,
134
- "gzip": 53933
133
+ "size": 253895,
134
+ "gzip": 53629
135
},
136
"react-test-renderer.development.js (NODE_DEV)": {
137
- "size": 264286,
138
- "gzip": 56152
137
+ "size": 262734,
138
+ "gzip": 55847
139
}
140
}
141
}
\ No newline at end of file
scripts/rollup/shims/rollup/ReactDebugCurrentFrameRollupShim.js
new
+3
@@ -0,0 +1,3 @@
1
+var ReactInternals = require('react').__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
2
+
3
+module.exports = ReactInternals.ReactDebugCurrentFrame;
src/fb/ReactFBEntry.js
+2
-1
@@ -27,8 +27,9 @@ if (__DEV__) {
27
Object.assign(
28
ReactFBEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
29
{
30
- // ReactComponentTreeHook should not be included in production.
30
+ // These should not be included in production.
31
ReactComponentTreeHook: require('react/lib/ReactComponentTreeHook'),
32
+ ReactDebugCurrentFrame: require('react/lib/ReactDebugCurrentFrame'),
33
},
34
);
35
}
src/umd/ReactUMDEntry.js
+2
-1
@@ -27,8 +27,9 @@ if (__DEV__) {
27
Object.assign(
28
ReactUMDEntry.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
29
{
30
- // ReactComponentTreeHook should not be included in production.
30
+ // These should not be included in production.
31
ReactComponentTreeHook: require('react/lib/ReactComponentTreeHook'),
32
+ ReactDebugCurrentFrame: require('react/lib/ReactDebugCurrentFrame'),
33
},
34
);
35
}