-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove platform checks from production bundle, fixes #1162
- Loading branch information
Showing
3 changed files
with
19 additions
and
1,978 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,21 +1,23 @@ | ||
'use strict' | ||
|
||
var evalAllowed = false; | ||
try { | ||
eval('evalAllowed = true'); | ||
} catch (e) { | ||
// eval not allowed due to CSP | ||
} | ||
if (!module.hot || process.env.NODE_ENV === 'production') { | ||
module.exports = require('./dist/react-hot-loader.production.min.js'); | ||
} else { | ||
var evalAllowed = false; | ||
try { | ||
eval('evalAllowed = true'); | ||
} catch (e) { | ||
// eval not allowed due to CSP | ||
} | ||
|
||
// RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods | ||
var platformSupported = !!Object.setPrototypeOf && evalAllowed; | ||
// RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods | ||
var jsFeaturesPresent = typeof window !== 'undefined' && !!Object.setPrototypeOf; | ||
|
||
if (!module.hot || process.env.NODE_ENV === 'production' || !platformSupported) { | ||
if (module.hot) { | ||
if (!jsFeaturesPresent && evalAllowed) { | ||
// we are not in prod mode, but RHL could not be activated | ||
console.warn('React-Hot-Loaded is not supported in this environment'); | ||
console.warn('React-Hot-Loader is not supported in this environment'); | ||
module.exports = require('./dist/react-hot-loader.production.min.js'); | ||
} else { | ||
module.exports = window.reactHotLoaderGlobal = require('./dist/react-hot-loader.development.js'); | ||
} | ||
module.exports = require('./dist/react-hot-loader.production.min.js'); | ||
} else { | ||
module.exports = require('./dist/react-hot-loader.development.js'); | ||
} |
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
Oops, something went wrong.