UNPKG

1.36 kBJavaScriptView Raw
1'use strict';
2
3function 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
31if (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.production.min.js');
36} else {
37 module.exports = require('./cjs/react-dom.development.js');
38}