Skip to content

Commit 9561d66

Browse files
committed
fix: explain why RHL could not be activated, fixes #1362
1 parent af42c1a commit 9561d66

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,28 @@ if (process.env.NODE_ENV === 'production') {
1313
module.exports.hot.shouldWrapWithAppContainer = true;
1414
} else {
1515
var evalAllowed = false;
16+
var evalError = null;
1617
try {
1718
eval('evalAllowed = true');
1819
} catch (e) {
1920
// eval not allowed due to CSP
21+
evalError = e && e.message ? e.message : 'unknown reason';
2022
}
2123

24+
// TODO: dont use eval to update methods. see #1273
2225
// RHL needs setPrototypeOf to operate Component inheritance, and eval to patch methods
2326
var jsFeaturesPresent = !!Object.setPrototypeOf;
2427

2528
if (!jsFeaturesPresent || !evalAllowed) {
2629
// we are not in prod mode, but RHL could not be activated
27-
console.warn('React-Hot-Loader is not supported in this environment.');
30+
console.warn(
31+
'React-Hot-Loader is not supported in this environment:',
32+
[
33+
!jsFeaturesPresent && "some JS features are missing",
34+
!evalAllowed && "`eval` is not allowed(" + evalError + ")"
35+
].join(','),
36+
'.'
37+
);
2838
module.exports = require('./dist/react-hot-loader.production.min.js');
2939
} else {
3040
module.exports = window.reactHotLoaderGlobal = require('./dist/react-hot-loader.development.js');

0 commit comments

Comments
 (0)