Skip to content

Commit

Permalink
fix: remove circular deps from hot-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Aug 4, 2019
1 parent 4310fa8 commit 2cb544d
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 128 deletions.
6 changes: 3 additions & 3 deletions src/babel.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ function plugin(args, options = {}) {

const headerTemplate = template(
`(function () {
var enterModule = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal : require('react-hot-loader')).enterModule;
var enterModule = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined);
enterModule && enterModule(module);
}())`,
templateOptions,
);
const footerTemplate = template(
`(function () {
var leaveModule = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal : require('react-hot-loader')).leaveModule;
var leaveModule = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined);
leaveModule && leaveModule(module);
}())`,
templateOptions,
Expand All @@ -61,7 +61,7 @@ function plugin(args, options = {}) {
`
(function () {
var reactHotLoader = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal : require('react-hot-loader')).default;
var reactHotLoader = (typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined);
if (!reactHotLoader) {
return;
Expand Down
6 changes: 1 addition & 5 deletions src/webpack/webpackTagCommonJSExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
void (function register() {
// eslint-disable-line no-extra-semi
/* react-hot-loader/webpack */
var safe_require = function() {
return typeof require === 'undefined' ? undefined : require('react-hot-loader');
};

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

if (!reactHotLoader) {
return;
Expand Down
Loading

0 comments on commit 2cb544d

Please sign in to comment.