Skip to content

Commit b3e14e7

Browse files
committed
Fix react-hot-loader error by providing module id
1 parent bd44ef7 commit b3e14e7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

inc/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ function main(
553553

554554
initModule: function(name, module) {
555555
// Set module.id for react-hot-loader support.
556-
module.id = name;
556+
module.id = moduleMeta[name] ? moduleMeta[name].index : name;
557557

558558
runtimeModuleInfo[name].module = module;
559559
module.hot = {

index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,13 @@ module.exports = function(bundle, opts) {
227227
}
228228

229229
function fileKey(filename) {
230-
return path.relative(basedir, filename);
230+
const relative = path.relative(basedir, filename);
231+
if (/^[a-zA-Z0-9]/.test(relative)) {
232+
// Example: return ./Label.jsx instead of Label.jsx - reverse module id
233+
// lookup would not work with just Label.jsx
234+
return './' + relative
235+
}
236+
return relative
231237
}
232238

233239
var hmrManagerFilename;

0 commit comments

Comments
 (0)