Skip to content

Commit

Permalink
fix: webpack-plugin - use RHL global variable, fixes #1251
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed May 16, 2019
1 parent eae4e65 commit f036d36
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/webpack/webpackTagCommonJSExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
(function register() {
// eslint-disable-line no-extra-semi
/* react-hot-loader/webpack */
const reactHotLoader = require('react-hot-loader').default;
var safe_require = function() {
return typeof require === 'undefined' ? undefined : require('react-hot-loader');
};

var reactHotLoader = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal : safe_require()).default;

if (!reactHotLoader) {
return;
Expand All @@ -13,6 +17,9 @@
/* eslint-disable camelcase, no-undef */
const webpackExports = typeof __webpack_exports__ !== 'undefined' ? __webpack_exports__ : exports;
/* eslint-enable camelcase, no-undef */
if (!webpackExports) {
return;
}

if (typeof webpackExports === 'function') {
reactHotLoader.register(webpackExports, 'module.exports', __FILENAME__);
Expand Down

0 comments on commit f036d36

Please sign in to comment.