11const injectionStart = {
2+ '16.13' : [
3+ 'isCompatibleFamilyForHotReloading(child, element)' ,
4+ 'hotCompareElements(child.elementType, element.type, hotUpdateChild(child), child.type)'
5+ ] ,
26 '16.10' : [
37 '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)))' ,
48 'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : hotCompareElements(child.elementType, element.type, hotUpdateChild(child), child.type))'
@@ -26,7 +30,10 @@ const injectionStart = {
2630} ;
2731
2832const additional = {
29-
33+ '16.13-update' : [
34+ 'isCompatibleFamilyForHotReloading(current, element)' ,
35+ 'hotCompareElements(current.elementType, element.type, hotUpdateChild(current), current.type)'
36+ ] ,
3037 '16.10-update' : [
3138 'current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:\n isCompatibleFamilyForHotReloading(current$$1, element)))' ,
3239 '(hotCompareElements(current$$1.elementType, element.type, hotUpdateChild(current$$1), current$$1.type)))'
@@ -63,7 +70,8 @@ const additional = {
6370 ]
6471} ;
6572
66- const ReactHotLoaderInjection = `
73+
74+ const reactHotLoaderCode = `
6775var hotUpdateChild = function (child) {
6876 return function (newType) {
6977 child.type = newType;
@@ -80,54 +88,79 @@ var hotCompareElements = function (oldType, newType) {
8088};
8189var hotCleanupHooks = function () {
8290 if (typeof resetHooks !== 'undefined') {
83- resetHooks();
91+ resetHooks();
8492 }
8593}
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;
101106 }
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,
115134` ;
116135
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+ ` ;
118150
119- const defaultEndCompact = [ 'var ReactDOM={ ' , ReactHotLoaderInjection ] ;
151+ const esmEnd = [ 'exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; ' , ESM ] ;
120152
121153const 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 ,
128161} ;
129162
130- const sign = '/* 🔥 this is hot-loader/react-dom 4.8+ 🔥 */' ;
163+ const sign = '/* 🔥 this is hot-loader/react-dom 🔥 */' ;
131164
132165function additionalTransform ( source ) {
133166 for ( const key in additional ) {
0 commit comments