Skip to content

Commit 4e744be

Browse files
authored
Added react-dom/profiling entry point to NPM package (#13570)
1 parent bb62722 commit 4e744be

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"LICENSE",
2626
"README.md",
2727
"index.js",
28+
"profiling.js",
2829
"server.js",
2930
"server.browser.js",
3031
"server.node.js",

0 commit comments

Comments
 (0)