Skip to content

Commit

Permalink
Fix module push/pop tracking
Browse files Browse the repository at this point in the history
Reviewed By: threepointone, cpojer

Differential Revision: D15983911

fbshipit-source-id: 9006b82984f326f4160a7e526552cab250e33efd
  • Loading branch information
gaearon authored and facebook-github-bot committed Jun 25, 2019
1 parent 4ac99e6 commit affd060
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/metro/src/lib/polyfills/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const EMPTY = {};
const {hasOwnProperty} = {};

if (__DEV__) {
var RefreshRegNoop = () => {};
var RefreshSigNoop = () => type => type;
global.$RefreshReg$ = () => {};
global.$RefreshSig$ = () => type => type;
}

function clear(): ModuleList {
Expand Down Expand Up @@ -351,16 +351,15 @@ function loadModuleImplementation(
if (__DEV__) {
moduleObject.hot = module.hot;

var prevRefreshReg = global.$RefreshReg$;
var prevRefreshSig = global.$RefreshSig$;
if (Refresh != null) {
const RefreshRuntime = Refresh;
global.$RefreshReg$ = (type, id) => {
RefreshRuntime.register(type, moduleId + ' ' + id);
};
global.$RefreshSig$ =
RefreshRuntime.createSignatureFunctionForTransform;
} else {
global.$RefreshReg$ = RefreshRegNoop;
global.$RefreshSig$ = RefreshSigNoop;
}
}
moduleObject.id = moduleId;
Expand Down Expand Up @@ -396,8 +395,6 @@ function loadModuleImplementation(
);
}

global.$RefreshReg$ = RefreshRegNoop;
global.$RefreshSig$ = RefreshSigNoop;
if (Refresh != null) {
const isRefreshBoundary = registerExportsForReactRefresh(
Refresh,
Expand Down Expand Up @@ -427,6 +424,8 @@ function loadModuleImplementation(
'initializingModuleIds is corrupt; something is terribly wrong',
);
}
global.$RefreshReg$ = prevRefreshReg;
global.$RefreshSig$ = prevRefreshSig;
}
}
}
Expand Down

0 comments on commit affd060

Please sign in to comment.