Added react-dom/profiling entry point to NPM package (#13570)
Brian Vaughn committed
Sep 5, 2018 at 11:16 UTC
4e744be6eecc86be2db87b7804a8bebedf4329b3
2 files changed
+39
packages/react-dom/npm/profiling.js
new
+38
@@ -0,0 +1,38 @@
1
+'use strict';
2
+
3
+function checkDCE() {
4
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
5
+ if (
6
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||
7
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'
8
+ ) {
9
+ return;
10
+ }
11
+ if (process.env.NODE_ENV !== 'production') {
12
+ // This branch is unreachable because this function is only called
13
+ // in production, but the condition is true only in development.
14
+ // Therefore if the branch is still here, dead code elimination wasn't
15
+ // properly applied.
16
+ // Don't change the message. React DevTools relies on it. Also make sure
17
+ // this message doesn't occur elsewhere in this function, or it will cause
18
+ // a false positive.
19
+ throw new Error('^_^');
20
+ }
21
+ try {
22
+ // Verify that the code above has been dead code eliminated (DCE'd).
23
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
24
+ } catch (err) {
25
+ // DevTools shouldn't crash React, no matter what.
26
+ // We should still report in case we break this code.
27
+ console.error(err);
28
+ }
29
+}
30
+
31
+if (process.env.NODE_ENV === 'production') {
32
+ // DCE check should happen before ReactDOM bundle executes so that
33
+ // DevTools can report bad minification during injection.
34
+ checkDCE();
35
+ module.exports = require('./cjs/react-dom.profiling.min.js');
36
+} else {
37
+ module.exports = require('./cjs/react-dom.development.js');
38
+}
packages/react-dom/package.json
+1
@@ -25,6 +25,7 @@
25
"LICENSE",
26
"README.md",
27
"index.js",
28
+ "profiling.js",
29
"server.js",
30
"server.browser.js",
31
"server.node.js",