index.js 1.3 KB

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