@@ -29,19 +29,19 @@ const createHoc = (SourceComponent, TargetComponent) => {
29
29
return TargetComponent ;
30
30
} ;
31
31
32
- const makeHotExport = sourceModule => {
32
+ const makeHotExport = ( sourceModule , moduleId ) => {
33
33
const updateInstances = possibleError => {
34
34
if ( possibleError && possibleError instanceof Error ) {
35
35
console . error ( possibleError ) ;
36
36
return ;
37
37
}
38
- const module = hotModule ( sourceModule . id ) ;
38
+ const module = hotModule ( moduleId ) ;
39
39
clearTimeout ( module . updateTimeout ) ;
40
40
module . updateTimeout = setTimeout ( ( ) => {
41
41
try {
42
- requireIndirect ( sourceModule . id ) ;
42
+ requireIndirect ( moduleId ) ;
43
43
} catch ( e ) {
44
- console . error ( 'React-Hot-Loader: error detected while loading' , sourceModule . id ) ;
44
+ console . error ( 'React-Hot-Loader: error detected while loading' , moduleId ) ;
45
45
console . error ( e ) ;
46
46
}
47
47
module . instances . forEach ( inst => inst . forceUpdate ( ) ) ;
@@ -68,16 +68,19 @@ const makeHotExport = sourceModule => {
68
68
} ;
69
69
70
70
const hot = sourceModule => {
71
- if ( ! sourceModule || ! sourceModule . id ) {
71
+ if ( ! sourceModule || ! sourceModule . hot ) {
72
72
// this is fatal
73
- throw new Error ( 'React-hot-loader: `hot` could not find the `id` property in the `module` you have provided' ) ;
73
+ throw new Error ( 'React-hot-loader: `hot` could not find the `hot` method in the `module` you have provided' ) ;
74
+ }
75
+ const moduleId = sourceModule . id || sourceModule . i || sourceModule . filename ;
76
+ if ( ! moduleId ) {
77
+ throw new Error ( 'React-hot-loader: `hot` could not find the `name` of the the `module` you have provided' ) ;
74
78
}
75
- const moduleId = sourceModule . id ;
76
79
const module = hotModule ( moduleId ) ;
77
- makeHotExport ( sourceModule ) ;
80
+ makeHotExport ( sourceModule , moduleId ) ;
78
81
79
82
clearExceptions ( ) ;
80
- const failbackTimer = chargeFailbackTimer ( sourceModule . id ) ;
83
+ const failbackTimer = chargeFailbackTimer ( moduleId ) ;
81
84
let firstHotRegistered = false ;
82
85
83
86
// TODO: Ensure that all exports from this file are react components.
0 commit comments