metro-runtime 0.72.0 → 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.72.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');
@@ -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) {
@@ -279,6 +279,20 @@ function metroImportAll(moduleId: ModuleID | VerboseModuleNameForDev | number) {
279
279
  }
280
280
  metroRequire.importAll = metroImportAll;
281
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
+
282
296
  let inGuard = false;
283
297
  function guardedLoadModule(
284
298
  moduleId: ModuleID,