metro-runtime 0.82.3 → 0.82.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/polyfills/require.js
CHANGED
|
@@ -9,8 +9,8 @@ const EMPTY = {};
|
|
|
9
9
|
const CYCLE_DETECTED = {};
|
|
10
10
|
const { hasOwnProperty } = {};
|
|
11
11
|
if (__DEV__) {
|
|
12
|
-
global.$RefreshReg$ = () => {};
|
|
13
|
-
global.$RefreshSig$ = () => (type) => type;
|
|
12
|
+
global.$RefreshReg$ = global.$RefreshReg$ ?? (() => {});
|
|
13
|
+
global.$RefreshSig$ = global.$RefreshSig$ ?? (() => (type) => type);
|
|
14
14
|
}
|
|
15
15
|
function clear() {
|
|
16
16
|
modules = new Map();
|
|
@@ -58,7 +58,13 @@ function define(factory, moduleId, dependencyMap) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function metroRequire(moduleId) {
|
|
61
|
+
function metroRequire(moduleId, maybeNameForDev) {
|
|
62
|
+
if (moduleId === null) {
|
|
63
|
+
if (__DEV__ && typeof maybeNameForDev === "string") {
|
|
64
|
+
throw new Error("Cannot find module '" + maybeNameForDev + "'");
|
|
65
|
+
}
|
|
66
|
+
throw new Error("Cannot find module");
|
|
67
|
+
}
|
|
62
68
|
if (__DEV__ && typeof moduleId === "string") {
|
|
63
69
|
const verboseName = moduleId;
|
|
64
70
|
moduleId = getModuleIdForVerboseName(verboseName);
|
|
@@ -267,7 +273,9 @@ function loadModuleImplementation(moduleId, module) {
|
|
|
267
273
|
if (Refresh != null) {
|
|
268
274
|
const RefreshRuntime = Refresh;
|
|
269
275
|
global.$RefreshReg$ = (type, id) => {
|
|
270
|
-
|
|
276
|
+
const prefixedModuleId =
|
|
277
|
+
__METRO_GLOBAL_PREFIX__ + " " + moduleId + " " + id;
|
|
278
|
+
RefreshRuntime.register(type, prefixedModuleId);
|
|
271
279
|
};
|
|
272
280
|
global.$RefreshSig$ =
|
|
273
281
|
RefreshRuntime.createSignatureFunctionForTransform;
|
|
@@ -290,7 +298,12 @@ function loadModuleImplementation(moduleId, module) {
|
|
|
290
298
|
if (__DEV__) {
|
|
291
299
|
Systrace.endEvent();
|
|
292
300
|
if (Refresh != null) {
|
|
293
|
-
|
|
301
|
+
const prefixedModuleId = __METRO_GLOBAL_PREFIX__ + " " + moduleId;
|
|
302
|
+
registerExportsForReactRefresh(
|
|
303
|
+
Refresh,
|
|
304
|
+
moduleObject.exports,
|
|
305
|
+
prefixedModuleId
|
|
306
|
+
);
|
|
294
307
|
}
|
|
295
308
|
}
|
|
296
309
|
return moduleObject.exports;
|
|
@@ -689,7 +702,9 @@ if (__DEV__) {
|
|
|
689
702
|
};
|
|
690
703
|
var requireRefresh = function requireRefresh() {
|
|
691
704
|
return (
|
|
692
|
-
global[__METRO_GLOBAL_PREFIX__ + "__ReactRefresh"] ||
|
|
705
|
+
global[__METRO_GLOBAL_PREFIX__ + "__ReactRefresh"] ||
|
|
706
|
+
global[global.__METRO_GLOBAL_PREFIX__ + "__ReactRefresh"] ||
|
|
707
|
+
metroRequire.Refresh
|
|
693
708
|
);
|
|
694
709
|
};
|
|
695
710
|
}
|
|
@@ -94,8 +94,8 @@ const CYCLE_DETECTED = {};
|
|
|
94
94
|
const {hasOwnProperty} = {};
|
|
95
95
|
|
|
96
96
|
if (__DEV__) {
|
|
97
|
-
global.$RefreshReg$ = () => {};
|
|
98
|
-
global.$RefreshSig$ = () => type => type;
|
|
97
|
+
global.$RefreshReg$ = global.$RefreshReg$ ?? (() => {});
|
|
98
|
+
global.$RefreshSig$ = global.$RefreshSig$ ?? (() => type => type);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function clear(): ModuleList {
|
|
@@ -169,7 +169,19 @@ function define(
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
function metroRequire(
|
|
172
|
+
function metroRequire(
|
|
173
|
+
moduleId: ModuleID | VerboseModuleNameForDev | null,
|
|
174
|
+
maybeNameForDev?: string,
|
|
175
|
+
): Exports {
|
|
176
|
+
// Unresolved optional dependencies are nulls in dependency maps
|
|
177
|
+
// eslint-disable-next-line lint/strictly-null
|
|
178
|
+
if (moduleId === null) {
|
|
179
|
+
if (__DEV__ && typeof maybeNameForDev === 'string') {
|
|
180
|
+
throw new Error("Cannot find module '" + maybeNameForDev + "'");
|
|
181
|
+
}
|
|
182
|
+
throw new Error('Cannot find module');
|
|
183
|
+
}
|
|
184
|
+
|
|
173
185
|
if (__DEV__ && typeof moduleId === 'string') {
|
|
174
186
|
const verboseName = moduleId;
|
|
175
187
|
moduleId = getModuleIdForVerboseName(verboseName);
|
|
@@ -459,7 +471,10 @@ function loadModuleImplementation(
|
|
|
459
471
|
if (Refresh != null) {
|
|
460
472
|
const RefreshRuntime = Refresh;
|
|
461
473
|
global.$RefreshReg$ = (type, id) => {
|
|
462
|
-
|
|
474
|
+
// prefix the id with global prefix to enable multiple HMR clients
|
|
475
|
+
const prefixedModuleId =
|
|
476
|
+
__METRO_GLOBAL_PREFIX__ + ' ' + moduleId + ' ' + id;
|
|
477
|
+
RefreshRuntime.register(type, prefixedModuleId);
|
|
463
478
|
};
|
|
464
479
|
global.$RefreshSig$ =
|
|
465
480
|
RefreshRuntime.createSignatureFunctionForTransform;
|
|
@@ -492,7 +507,13 @@ function loadModuleImplementation(
|
|
|
492
507
|
Systrace.endEvent();
|
|
493
508
|
|
|
494
509
|
if (Refresh != null) {
|
|
495
|
-
|
|
510
|
+
// prefix the id with global prefix to enable multiple HMR clients
|
|
511
|
+
const prefixedModuleId = __METRO_GLOBAL_PREFIX__ + ' ' + moduleId;
|
|
512
|
+
registerExportsForReactRefresh(
|
|
513
|
+
Refresh,
|
|
514
|
+
moduleObject.exports,
|
|
515
|
+
prefixedModuleId,
|
|
516
|
+
);
|
|
496
517
|
}
|
|
497
518
|
}
|
|
498
519
|
|
|
@@ -986,7 +1007,7 @@ if (__DEV__) {
|
|
|
986
1007
|
var registerExportsForReactRefresh = (
|
|
987
1008
|
Refresh: any,
|
|
988
1009
|
moduleExports: Exports,
|
|
989
|
-
moduleID:
|
|
1010
|
+
moduleID: string,
|
|
990
1011
|
) => {
|
|
991
1012
|
Refresh.register(moduleExports, moduleID + ' %exports%');
|
|
992
1013
|
if (moduleExports == null || typeof moduleExports !== 'object') {
|
|
@@ -1024,9 +1045,16 @@ if (__DEV__) {
|
|
|
1024
1045
|
};
|
|
1025
1046
|
|
|
1026
1047
|
var requireRefresh = function requireRefresh() {
|
|
1048
|
+
// __METRO_GLOBAL_PREFIX__ and global.__METRO_GLOBAL_PREFIX__ differ from
|
|
1049
|
+
// each other when multiple module systems are used - e.g, in the context
|
|
1050
|
+
// of Module Federation, the first one would refer to the local prefix
|
|
1051
|
+
// defined at the top of the bundle, while the other always refers to the
|
|
1052
|
+
// one coming from the Host
|
|
1027
1053
|
return (
|
|
1054
|
+
global[__METRO_GLOBAL_PREFIX__ + '__ReactRefresh'] ||
|
|
1055
|
+
global[global.__METRO_GLOBAL_PREFIX__ + '__ReactRefresh'] ||
|
|
1028
1056
|
// $FlowFixMe[prop-missing]
|
|
1029
|
-
|
|
1057
|
+
metroRequire.Refresh
|
|
1030
1058
|
);
|
|
1031
1059
|
};
|
|
1032
1060
|
}
|