Skip to content
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'
);

// Checks if this is global space to catch
// execution in node environments and use 'unstable_no_dom'
//
// 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');
}