-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Bug MessageChannel in Node Envs (issue #20756)
- Loading branch information
Showing
1 changed file
with
20 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} |