Skip to content

Commit

Permalink
Fix Bug MessageChannel in Node Envs (issue #20756)
Browse files Browse the repository at this point in the history
  • Loading branch information
amensum committed Feb 10, 2021
1 parent b06a1cc commit 10e587c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/scheduler/npm/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
'use strict';

if (typeof window === 'undefined' || typeof MessageChannel !== 'function') {
module.exports = require('./unstable_no_dom');
} else if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/scheduler.production.min.js');
// Duplicated from 'react/packages/shared/ExecutionEnvironment.js'
var canUseDom = !!(
typeof window !== 'undefined' &&
typeof window.document !== 'undefined' &&
typeof window.document.createElement !== 'undefined'
);

// Node environment has cycled global reference
var isCycledGlobal = !!(
typeof global !== 'undefined' &&
global.global === global
);

if (canUseDom && !isCycledGlobal) {
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/scheduler.production.min.js');
} else {
module.exports = require('./cjs/scheduler.development.js');
}
} else {
module.exports = require('./cjs/scheduler.development.js');
module.exports = require('./unstable_no_dom');
}

0 comments on commit 10e587c

Please sign in to comment.