Skip to content

Commit f026429

Browse files
fix: restore original hot reloading behaviour for locals (#419)
1 parent f4cf0d2 commit f026429

File tree

2 files changed

+16
-31
lines changed

2 files changed

+16
-31
lines changed

src/index.js

+15-31
Original file line numberDiff line numberDiff line change
@@ -132,39 +132,23 @@ ${hmrCode}
132132
const hmrCode = this.hot
133133
? `
134134
if (module.hot) {
135-
module.hot.accept(
136-
${loaderUtils.stringifyRequest(this, `!!${request}`)},
137-
function() {
138-
var newContent = require(${loaderUtils.stringifyRequest(
139-
this,
140-
`!!${request}`
141-
)});
142-
143-
if (typeof newContent === 'string') {
144-
newContent = [[module.id, newContent, '']];
145-
}
146-
147-
var locals = (function(a, b) {
148-
var key,
149-
idx = 0;
150-
151-
for (key in a) {
152-
if(!b || a[key] !== b[key]) return false;
153-
idx++;
135+
if (!content.locals) {
136+
module.hot.accept(
137+
${loaderUtils.stringifyRequest(this, `!!${request}`)},
138+
function () {
139+
var newContent = require(${loaderUtils.stringifyRequest(
140+
this,
141+
`!!${request}`
142+
)});
143+
144+
if (typeof newContent === 'string') {
145+
newContent = [[module.id, newContent, '']];
154146
}
155-
156-
for (key in b) idx--;
157-
158-
return idx === 0;
159-
}(content.locals, newContent.locals));
160-
161-
if (!locals) {
162-
throw new Error('Aborting CSS HMR due to changed css-modules locals.');
147+
148+
update(newContent);
163149
}
164-
165-
update(newContent);
166-
}
167-
);
150+
)
151+
}
168152
169153
module.hot.dispose(function() {
170154
update();

test/manual/webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const ENABLE_SOURCE_MAP =
66
: false;
77

88
module.exports = {
9+
devtool: ENABLE_SOURCE_MAP ? 'source-map' : false,
910
mode: 'development',
1011
output: {
1112
publicPath: '/dist/',

0 commit comments

Comments
 (0)