metro-runtime 0.71.2 → 0.72.1
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.1",
|
|
4
4
|
"description": "🚇 Module required for evaluating Metro bundles.",
|
|
5
5
|
"main": "src",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@babel/runtime": "^7.0.0"
|
|
16
|
+
"@babel/runtime": "^7.0.0",
|
|
17
|
+
"react-refresh": "^0.4.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@babel/core": "^7.14.0"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @format
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
module.exports = require("react-refresh/runtime");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @flow
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = require('react-refresh/runtime');
|
package/src/polyfills/require.js
CHANGED
|
@@ -23,7 +23,7 @@ const CYCLE_DETECTED = {};
|
|
|
23
23
|
const { hasOwnProperty } = {};
|
|
24
24
|
|
|
25
25
|
if (__DEV__) {
|
|
26
|
-
global.$RefreshReg$ = () => {};
|
|
26
|
+
global.$RefreshReg$ = () => {}; // $FlowFixMe[missing-local-annot]
|
|
27
27
|
|
|
28
28
|
global.$RefreshSig$ = () => (type) => type;
|
|
29
29
|
}
|
|
@@ -207,7 +207,22 @@ function metroImportAll(moduleId) {
|
|
|
207
207
|
return (modules[moduleIdReallyIsNumber].importedAll = importedAll);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
metroRequire.importAll = metroImportAll;
|
|
210
|
+
metroRequire.importAll = metroImportAll; // The `require.context()` syntax is never executed in the runtime because it is converted
|
|
211
|
+
// to `require()` in `metro/src/ModuleGraph/worker/collectDependencies.js` after collecting
|
|
212
|
+
// dependencies. If the feature flag is not enabled then the conversion never takes place and this error is thrown (development only).
|
|
213
|
+
|
|
214
|
+
metroRequire.context = function fallbackRequireContext() {
|
|
215
|
+
if (__DEV__) {
|
|
216
|
+
throw new Error(
|
|
217
|
+
"The experimental Metro feature `require.context` is not enabled in your project.\nThis can be enabled by setting the `transformer.unstable_allowRequireContext` property to `true` in your Metro configuration."
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
throw new Error(
|
|
222
|
+
"The experimental Metro feature `require.context` is not enabled in your project."
|
|
223
|
+
);
|
|
224
|
+
};
|
|
225
|
+
|
|
211
226
|
let inGuard = false;
|
|
212
227
|
|
|
213
228
|
function guardedLoadModule(moduleId, module) {
|
|
@@ -79,6 +79,7 @@ const {hasOwnProperty} = {};
|
|
|
79
79
|
|
|
80
80
|
if (__DEV__) {
|
|
81
81
|
global.$RefreshReg$ = () => {};
|
|
82
|
+
// $FlowFixMe[missing-local-annot]
|
|
82
83
|
global.$RefreshSig$ = () => type => type;
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -205,7 +206,7 @@ function shouldPrintRequireCycle(modules: $ReadOnlyArray<?string>): boolean {
|
|
|
205
206
|
return true;
|
|
206
207
|
}
|
|
207
208
|
|
|
208
|
-
const isIgnored = module =>
|
|
209
|
+
const isIgnored = (module: ?string) =>
|
|
209
210
|
module != null && regExps.some(regExp => regExp.test(module));
|
|
210
211
|
|
|
211
212
|
// Print the cycle unless any part of it is ignored
|
|
@@ -278,6 +279,20 @@ function metroImportAll(moduleId: ModuleID | VerboseModuleNameForDev | number) {
|
|
|
278
279
|
}
|
|
279
280
|
metroRequire.importAll = metroImportAll;
|
|
280
281
|
|
|
282
|
+
// The `require.context()` syntax is never executed in the runtime because it is converted
|
|
283
|
+
// to `require()` in `metro/src/ModuleGraph/worker/collectDependencies.js` after collecting
|
|
284
|
+
// dependencies. If the feature flag is not enabled then the conversion never takes place and this error is thrown (development only).
|
|
285
|
+
metroRequire.context = function fallbackRequireContext() {
|
|
286
|
+
if (__DEV__) {
|
|
287
|
+
throw new Error(
|
|
288
|
+
'The experimental Metro feature `require.context` is not enabled in your project.\nThis can be enabled by setting the `transformer.unstable_allowRequireContext` property to `true` in your Metro configuration.',
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
throw new Error(
|
|
292
|
+
'The experimental Metro feature `require.context` is not enabled in your project.',
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
|
|
281
296
|
let inGuard = false;
|
|
282
297
|
function guardedLoadModule(
|
|
283
298
|
moduleId: ModuleID,
|
|
@@ -867,7 +882,10 @@ if (__DEV__) {
|
|
|
867
882
|
};
|
|
868
883
|
|
|
869
884
|
// Modules that only export components become React Refresh boundaries.
|
|
870
|
-
var isReactRefreshBoundary = function (
|
|
885
|
+
var isReactRefreshBoundary = function (
|
|
886
|
+
Refresh: any,
|
|
887
|
+
moduleExports: Exports,
|
|
888
|
+
): boolean {
|
|
871
889
|
if (Refresh.isLikelyComponentType(moduleExports)) {
|
|
872
890
|
return true;
|
|
873
891
|
}
|
|
@@ -896,9 +914,9 @@ if (__DEV__) {
|
|
|
896
914
|
};
|
|
897
915
|
|
|
898
916
|
var shouldInvalidateReactRefreshBoundary = (
|
|
899
|
-
Refresh,
|
|
900
|
-
prevExports,
|
|
901
|
-
nextExports,
|
|
917
|
+
Refresh: any,
|
|
918
|
+
prevExports: Exports,
|
|
919
|
+
nextExports: Exports,
|
|
902
920
|
) => {
|
|
903
921
|
const prevSignature = getRefreshBoundarySignature(Refresh, prevExports);
|
|
904
922
|
const nextSignature = getRefreshBoundarySignature(Refresh, nextExports);
|
|
@@ -914,7 +932,10 @@ if (__DEV__) {
|
|
|
914
932
|
};
|
|
915
933
|
|
|
916
934
|
// When this signature changes, it's unsafe to stop at this refresh boundary.
|
|
917
|
-
var getRefreshBoundarySignature = (
|
|
935
|
+
var getRefreshBoundarySignature = (
|
|
936
|
+
Refresh: any,
|
|
937
|
+
moduleExports: Exports,
|
|
938
|
+
): Array<mixed> => {
|
|
918
939
|
const signature = [];
|
|
919
940
|
signature.push(Refresh.getFamilyByType(moduleExports));
|
|
920
941
|
if (moduleExports == null || typeof moduleExports !== 'object') {
|
|
@@ -937,7 +958,11 @@ if (__DEV__) {
|
|
|
937
958
|
return signature;
|
|
938
959
|
};
|
|
939
960
|
|
|
940
|
-
var registerExportsForReactRefresh = (
|
|
961
|
+
var registerExportsForReactRefresh = (
|
|
962
|
+
Refresh: any,
|
|
963
|
+
moduleExports: Exports,
|
|
964
|
+
moduleID: ModuleID,
|
|
965
|
+
) => {
|
|
941
966
|
Refresh.register(moduleExports, moduleID + ' %exports%');
|
|
942
967
|
if (moduleExports == null || typeof moduleExports !== 'object') {
|
|
943
968
|
// Exit if we can't iterate over exports.
|