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 12, 2021
1 parent f519728 commit c1394ea
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/scheduler/npm/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
'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'
);

// Checks if this is global space
// eslint-disable-next-line no-undef
var isThisGlobal = !!(typeof globalThis !== 'undefined' && globalThis === this);

if (canUseDom && isThisGlobal) {
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 c1394ea

Please sign in to comment.