Skip to content

Commit f036d36

Browse files
committed
fix: webpack-plugin - use RHL global variable, fixes #1251
1 parent eae4e65 commit f036d36

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/webpack/webpackTagCommonJSExports.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
(function register() {
55
// eslint-disable-line no-extra-semi
66
/* react-hot-loader/webpack */
7-
const reactHotLoader = require('react-hot-loader').default;
7+
var safe_require = function() {
8+
return typeof require === 'undefined' ? undefined : require('react-hot-loader');
9+
};
10+
11+
var reactHotLoader = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal : safe_require()).default;
812

913
if (!reactHotLoader) {
1014
return;
@@ -13,6 +17,9 @@
1317
/* eslint-disable camelcase, no-undef */
1418
const webpackExports = typeof __webpack_exports__ !== 'undefined' ? __webpack_exports__ : exports;
1519
/* eslint-enable camelcase, no-undef */
20+
if (!webpackExports) {
21+
return;
22+
}
1623

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

0 commit comments

Comments
 (0)