Skip to content

Commit

Permalink
fix: restore original hot reloading behaviour for locals (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Aug 5, 2019
1 parent f4cf0d2 commit f026429
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
46 changes: 15 additions & 31 deletions src/index.js
Expand Up @@ -132,39 +132,23 @@ ${hmrCode}
const hmrCode = this.hot
? `
if (module.hot) {
module.hot.accept(
${loaderUtils.stringifyRequest(this, `!!${request}`)},
function() {
var newContent = require(${loaderUtils.stringifyRequest(
this,
`!!${request}`
)});
if (typeof newContent === 'string') {
newContent = [[module.id, newContent, '']];
}
var locals = (function(a, b) {
var key,
idx = 0;
for (key in a) {
if(!b || a[key] !== b[key]) return false;
idx++;
if (!content.locals) {
module.hot.accept(
${loaderUtils.stringifyRequest(this, `!!${request}`)},
function () {
var newContent = require(${loaderUtils.stringifyRequest(
this,
`!!${request}`
)});
if (typeof newContent === 'string') {
newContent = [[module.id, newContent, '']];
}
for (key in b) idx--;
return idx === 0;
}(content.locals, newContent.locals));
if (!locals) {
throw new Error('Aborting CSS HMR due to changed css-modules locals.');
update(newContent);
}
update(newContent);
}
);
)
}
module.hot.dispose(function() {
update();
Expand Down
1 change: 1 addition & 0 deletions test/manual/webpack.config.js
Expand Up @@ -6,6 +6,7 @@ const ENABLE_SOURCE_MAP =
: false;

module.exports = {
devtool: ENABLE_SOURCE_MAP ? 'source-map' : false,
mode: 'development',
output: {
publicPath: '/dist/',
Expand Down

0 comments on commit f026429

Please sign in to comment.