1
1
const injectionStart = {
2
+ '16.13' : [
3
+ 'isCompatibleFamilyForHotReloading(child, element)' ,
4
+ 'hotCompareElements(child.elementType, element.type, hotUpdateChild(child), child.type)'
5
+ ] ,
2
6
'16.10' : [
3
7
'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(child, element)))' ,
4
8
'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : hotCompareElements(child.elementType, element.type, hotUpdateChild(child), child.type))'
@@ -26,7 +30,10 @@ const injectionStart = {
26
30
} ;
27
31
28
32
const additional = {
29
-
33
+ '16.13-update' : [
34
+ 'isCompatibleFamilyForHotReloading(current, element)' ,
35
+ 'hotCompareElements(current.elementType, element.type, hotUpdateChild(current), current.type)'
36
+ ] ,
30
37
'16.10-update' : [
31
38
'current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))' ,
32
39
'(hotCompareElements(current$$1.elementType, element.type, hotUpdateChild(current$$1), current$$1.type)))'
@@ -63,7 +70,8 @@ const additional = {
63
70
]
64
71
} ;
65
72
66
- const ReactHotLoaderInjection = `
73
+
74
+ const reactHotLoaderCode = `
67
75
var hotUpdateChild = function (child) {
68
76
return function (newType) {
69
77
child.type = newType;
@@ -80,54 +88,79 @@ var hotCompareElements = function (oldType, newType) {
80
88
};
81
89
var hotCleanupHooks = function () {
82
90
if (typeof resetHooks !== 'undefined') {
83
- resetHooks();
91
+ resetHooks();
84
92
}
85
93
}
86
- var ReactDOM = {
87
- evalInReactContext: function (injection) {
88
- return eval(injection);
89
- },
90
- hotCleanup: hotCleanupHooks,
91
- hotRenderWithHooks: function (current, render) {
92
- hotCleanupHooks();
93
-
94
- if (typeof nextCurrentHook !== 'undefined' && typeof ReactCurrentDispatcher$1 !== 'undefined') {
95
- nextCurrentHook = current !== null ? current.memoizedState : null;
96
- if(typeof firstCurrentHook !== 'undefined') {
97
- firstCurrentHook = nextCurrentHook;
98
- }
99
-
100
- ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
94
+
95
+ var evalInReactContext = function (injection) {
96
+ return eval(injection);
97
+ };
98
+ var hotCleanup = hotCleanupHooks;
99
+ var hotRenderWithHooks = function (current, render) {
100
+ hotCleanupHooks();
101
+
102
+ if (typeof nextCurrentHook !== 'undefined' && typeof ReactCurrentDispatcher$1 !== 'undefined') {
103
+ nextCurrentHook = current !== null ? current.memoizedState : null;
104
+ if (typeof firstCurrentHook !== 'undefined') {
105
+ firstCurrentHook = nextCurrentHook;
101
106
}
102
-
103
- var rendered = render();
104
-
105
- hotCleanupHooks();
106
-
107
- return rendered;
108
- },
109
- setHotElementComparator: function (newComparator) {
110
- hotCompareElements = newComparator
111
- },
112
- setHotTypeResolver: function (newResolver) {
113
- hotResolveType = newResolver;
114
- },
107
+
108
+ ReactCurrentDispatcher$1.current = nextCurrentHook === null ? HooksDispatcherOnMountInDEV : HooksDispatcherOnUpdateInDEV;
109
+ }
110
+
111
+ var rendered = render();
112
+
113
+ hotCleanupHooks();
114
+
115
+ return rendered;
116
+ }
117
+ var setHotElementComparator = function (newComparator) {
118
+ hotCompareElements = newComparator
119
+ };
120
+ var setHotTypeResolver = function (newResolver) {
121
+ hotResolveType = newResolver;
122
+ };
123
+ ` ;
124
+
125
+ const CJS = `
126
+ ${ reactHotLoaderCode } ;
127
+
128
+ var ReactDOM = {
129
+ evalInReactContext: evalInReactContext,
130
+ hotCleanup: hotCleanup,
131
+ hotRenderWithHooks: hotRenderWithHooks,
132
+ setHotElementComparator: setHotElementComparator,
133
+ setHotTypeResolver: setHotTypeResolver,
115
134
` ;
116
135
117
- const defaultEnd = [ 'var ReactDOM = {' , ReactHotLoaderInjection ] ;
136
+ const commonJSEnd = [ 'var ReactDOM = {' , CJS ] ;
137
+ const commonJSEndCompact = [ 'var ReactDOM={' , CJS ] ;
138
+
139
+ const ESM = `
140
+ ${ reactHotLoaderCode } ;
141
+
142
+ exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
143
+
144
+ exports.evalInReactContext= evalInReactContext,
145
+ exports.hotCleanup= hotCleanup,
146
+ exports.hotRenderWithHooks= hotRenderWithHooks,
147
+ exports.setHotElementComparator= setHotElementComparator,
148
+ exports.setHotTypeResolver= setHotTypeResolver,
149
+ ` ;
118
150
119
- const defaultEndCompact = [ 'var ReactDOM={ ' , ReactHotLoaderInjection ] ;
151
+ const esmEnd = [ 'exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; ' , ESM ] ;
120
152
121
153
const injectionEnd = {
122
- '16.10' : defaultEnd ,
123
- '16.9' : defaultEnd ,
124
- '16.6' : defaultEnd ,
125
- '16.4' : defaultEnd ,
126
- '16.6-compact' : defaultEndCompact ,
127
- '16.4-compact' : defaultEndCompact ,
154
+ '16.13' : esmEnd ,
155
+ '16.10' : commonJSEnd ,
156
+ '16.9' : commonJSEnd ,
157
+ '16.6' : commonJSEnd ,
158
+ '16.4' : commonJSEnd ,
159
+ '16.6-compact' : commonJSEndCompact ,
160
+ '16.4-compact' : commonJSEndCompact ,
128
161
} ;
129
162
130
- const sign = '/* 🔥 this is hot-loader/react-dom 4.8+ 🔥 */' ;
163
+ const sign = '/* 🔥 this is hot-loader/react-dom 🔥 */' ;
131
164
132
165
function additionalTransform ( source ) {
133
166
for ( const key in additional ) {
0 commit comments