-
Notifications
You must be signed in to change notification settings - Fork 801
/
index.js
42 lines (39 loc) · 1.55 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/react-hot-loader.production.min.js');
} else if (process.env.NODE_ENV === 'test') {
module.exports = require('./dist/react-hot-loader.production.min.js');
} else if (typeof window === 'undefined') {
// this is just server environment
module.exports = require('./dist/react-hot-loader.production.min.js');
} else if (!module.hot) {
module.exports = require('./dist/react-hot-loader.production.min.js');
module.exports.AppContainer.warnAboutHMRDisabled = true;
module.exports.hot.shouldWrapWithAppContainer = true;
} else {
var evalAllowed = false;
var evalError = null;
try {
eval('evalAllowed = true');
} catch (e) {
// eval not allowed due to CSP
evalError = e && e.message ? e.message : 'unknown reason';
}
// TODO: dont use eval to update methods. see #1273
// RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods
var jsFeaturesPresent = !!Object.setPrototypeOf;
if (!jsFeaturesPresent || !evalAllowed) {
// we are not in prod mode, but RHL could not be activated
console.warn(
'React-Hot-Loader is not supported in this environment:',
[
!jsFeaturesPresent && "some JS features are missing",
!evalAllowed && "`eval` is not allowed(" + evalError + ")"
].join(','),
'.'
);
module.exports = require('./dist/react-hot-loader.production.min.js');
} else {
module.exports = window.reactHotLoaderGlobal = require('./dist/react-hot-loader.development.js');
}
}