diff --git a/index.js b/index.js index 98dde5a8a..ab75c7e99 100644 --- a/index.js +++ b/index.js @@ -13,18 +13,28 @@ if (process.env.NODE_ENV === 'production') { 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.'); + 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');