metro 0.80.4 → 0.80.6

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.
Files changed (149) hide show
  1. package/package.json +16 -17
  2. package/src/Assets.js +0 -35
  3. package/src/Bundler/util.js +1 -29
  4. package/src/Bundler.js +1 -20
  5. package/src/DeltaBundler/DeltaCalculator.js +0 -86
  6. package/src/DeltaBundler/Graph.js +0 -197
  7. package/src/DeltaBundler/Serializers/baseJSBundle.js +0 -13
  8. package/src/DeltaBundler/Serializers/getAllFiles.js +0 -11
  9. package/src/DeltaBundler/Serializers/getAssets.js +0 -11
  10. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +0 -11
  11. package/src/DeltaBundler/Serializers/getRamBundleInfo.js +0 -18
  12. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +0 -11
  13. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +0 -11
  14. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +0 -14
  15. package/src/DeltaBundler/Serializers/helpers/js.js +0 -21
  16. package/src/DeltaBundler/Serializers/helpers/processModules.js +0 -11
  17. package/src/DeltaBundler/Serializers/hmrJSBundle.js +0 -23
  18. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +0 -16
  19. package/src/DeltaBundler/Serializers/sourceMapObject.js +0 -11
  20. package/src/DeltaBundler/Serializers/sourceMapString.js +0 -11
  21. package/src/DeltaBundler/Transformer.js +0 -30
  22. package/src/DeltaBundler/Worker.flow.js +0 -26
  23. package/src/DeltaBundler/Worker.flow.js.flow +2 -2
  24. package/src/DeltaBundler/Worker.js +0 -14
  25. package/src/DeltaBundler/WorkerFarm.js +1 -21
  26. package/src/DeltaBundler/__fixtures__/hasteImpl.js +0 -14
  27. package/src/DeltaBundler/buildSubgraph.js +0 -24
  28. package/src/DeltaBundler/getTransformCacheKey.js +0 -13
  29. package/src/DeltaBundler/getTransformCacheKey.js.flow +1 -1
  30. package/src/DeltaBundler/mergeDeltas.js +0 -11
  31. package/src/DeltaBundler/types.flow.js +0 -11
  32. package/src/DeltaBundler.js +0 -21
  33. package/src/HmrServer.js +8 -39
  34. package/src/HmrServer.js.flow +8 -6
  35. package/src/IncrementalBundler/GraphNotFoundError.js +0 -11
  36. package/src/IncrementalBundler/ResourceNotFoundError.js +0 -11
  37. package/src/IncrementalBundler/RevisionNotFoundError.js +0 -11
  38. package/src/IncrementalBundler.js +0 -23
  39. package/src/ModuleGraph/test-helpers.js +0 -17
  40. package/src/ModuleGraph/worker/JsFileWrapping.js +1 -22
  41. package/src/ModuleGraph/worker/collectDependencies.js +1 -94
  42. package/src/ModuleGraph/worker/generateImportNames.js +0 -15
  43. package/src/Server/MultipartResponse.js +0 -13
  44. package/src/Server/symbolicate.js +2 -36
  45. package/src/Server.js +6 -83
  46. package/src/cli/parseKeyValueParamArray.js +0 -11
  47. package/src/cli-utils.js +0 -11
  48. package/src/cli.js +0 -13
  49. package/src/commands/build.js +0 -15
  50. package/src/commands/dependencies.js +1 -19
  51. package/src/commands/serve.js +0 -19
  52. package/src/index.flow.js +0 -31
  53. package/src/index.js +0 -14
  54. package/src/integration_tests/basic_bundle/AssetRegistry.js +0 -10
  55. package/src/integration_tests/basic_bundle/Bar.js +0 -10
  56. package/src/integration_tests/basic_bundle/ErrorBundle.js +0 -12
  57. package/src/integration_tests/basic_bundle/Foo.js +0 -10
  58. package/src/integration_tests/basic_bundle/TestBigInt.js +0 -12
  59. package/src/integration_tests/basic_bundle/TestBundle.js +0 -11
  60. package/src/integration_tests/basic_bundle/TestPolyfill.js +0 -10
  61. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +0 -14
  62. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js +0 -14
  63. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js +0 -14
  64. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js +1 -15
  65. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js +0 -13
  66. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js +0 -16
  67. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +0 -14
  68. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js +0 -13
  69. package/src/integration_tests/basic_bundle/import-export/export-1.js +0 -10
  70. package/src/integration_tests/basic_bundle/import-export/export-2.js +0 -10
  71. package/src/integration_tests/basic_bundle/import-export/export-3.js +0 -10
  72. package/src/integration_tests/basic_bundle/import-export/export-4.js +0 -10
  73. package/src/integration_tests/basic_bundle/import-export/export-5.js +0 -10
  74. package/src/integration_tests/basic_bundle/import-export/export-6.js +0 -10
  75. package/src/integration_tests/basic_bundle/import-export/export-null.js +0 -10
  76. package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +0 -10
  77. package/src/integration_tests/basic_bundle/import-export/index.js +0 -10
  78. package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js +0 -10
  79. package/src/integration_tests/basic_bundle/polyfill.js +0 -12
  80. package/src/integration_tests/basic_bundle/require-context/conflict.js +0 -10
  81. package/src/integration_tests/basic_bundle/require-context/empty.js +0 -10
  82. package/src/integration_tests/basic_bundle/require-context/matching.js +0 -10
  83. package/src/integration_tests/basic_bundle/require-context/mode-eager.js +0 -10
  84. package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +0 -10
  85. package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +0 -10
  86. package/src/integration_tests/basic_bundle/require-context/mode-sync.js +0 -11
  87. package/src/integration_tests/basic_bundle/require-context/subdir/a.js +0 -10
  88. package/src/integration_tests/basic_bundle/require-context/subdir/b.js +0 -9
  89. package/src/integration_tests/basic_bundle/require-context/subdir/c.js +0 -10
  90. package/src/integration_tests/basic_bundle/require-context/subdir/nested/d.js +0 -10
  91. package/src/integration_tests/basic_bundle/require-context/subdir-conflict/index.js +0 -10
  92. package/src/integration_tests/basic_bundle/require-context/utils.js +0 -10
  93. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js +0 -15
  94. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js +0 -10
  95. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js +0 -10
  96. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js +0 -15
  97. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/counter-module.js +0 -10
  98. package/src/integration_tests/basic_bundle/require-resolveWeak/subdir/throwing-module.js +0 -10
  99. package/src/integration_tests/execBundle.js +0 -11
  100. package/src/integration_tests/metro.config.js +0 -10
  101. package/src/lib/BatchProcessor.js +0 -23
  102. package/src/lib/CountingSet.js +0 -35
  103. package/src/lib/JsonReporter.js +0 -17
  104. package/src/lib/RamBundleParser.js +0 -23
  105. package/src/lib/TerminalReporter.js +0 -68
  106. package/src/lib/bundleToString.js +1 -19
  107. package/src/lib/contextModule.js +1 -31
  108. package/src/lib/contextModuleTemplates.js +0 -36
  109. package/src/lib/countLines.js +0 -11
  110. package/src/lib/createModuleIdFactory.js +0 -11
  111. package/src/lib/createWebsocketServer.js +0 -24
  112. package/src/lib/debounceAsyncQueue.js +0 -13
  113. package/src/lib/formatBundlingError.js +0 -14
  114. package/src/lib/getAppendScripts.js +0 -11
  115. package/src/lib/getGraphId.js +0 -11
  116. package/src/lib/getMaxWorkers.js +0 -11
  117. package/src/lib/getPreludeCode.js +0 -18
  118. package/src/lib/getPrependedScripts.js +0 -13
  119. package/src/lib/logToConsole.js +0 -18
  120. package/src/lib/parseCustomResolverOptions.js +0 -11
  121. package/src/lib/parseCustomTransformOptions.js +0 -12
  122. package/src/lib/parseOptionsFromUrl.js +1 -17
  123. package/src/lib/relativizeSourceMap.js +0 -12
  124. package/src/lib/reporting.js +0 -30
  125. package/src/lib/splitBundleOptions.js +0 -14
  126. package/src/lib/transformHelpers.js +0 -20
  127. package/src/node-haste/DependencyGraph/ModuleResolution.js +5 -64
  128. package/src/node-haste/DependencyGraph/createFileMap.js +0 -16
  129. package/src/node-haste/DependencyGraph.js +6 -46
  130. package/src/node-haste/DependencyGraph.js.flow +7 -4
  131. package/src/node-haste/Module.js +0 -11
  132. package/src/node-haste/ModuleCache.js +0 -20
  133. package/src/node-haste/Package.js +0 -11
  134. package/src/node-haste/lib/AssetPaths.js +0 -16
  135. package/src/node-haste/lib/parsePlatformFilePath.js +0 -16
  136. package/src/shared/output/RamBundle/as-assets.js +6 -29
  137. package/src/shared/output/RamBundle/as-indexed-file.js +0 -44
  138. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +0 -13
  139. package/src/shared/output/RamBundle/magic-number.js +0 -11
  140. package/src/shared/output/RamBundle/util.js +1 -17
  141. package/src/shared/output/RamBundle/write-sourcemap.js +0 -12
  142. package/src/shared/output/RamBundle.js +0 -14
  143. package/src/shared/output/bundle.flow.js +0 -13
  144. package/src/shared/output/bundle.flow.js.flow +1 -1
  145. package/src/shared/output/bundle.js +0 -14
  146. package/src/shared/output/meta.js +0 -11
  147. package/src/shared/output/unbundle.js +0 -13
  148. package/src/shared/output/writeFile.js +0 -11
  149. package/src/shared/types.flow.js +0 -11
package/src/Server.js CHANGED
@@ -1,14 +1,3 @@
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
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
3
  const { getAsset } = require("./Assets");
@@ -72,11 +61,6 @@ class Server {
72
61
  this._logger = Logger;
73
62
  this._platforms = new Set(this._config.resolver.platforms);
74
63
  this._isEnded = false;
75
-
76
- // TODO(T34760917): These two properties should eventually be instantiated
77
- // elsewhere and passed as parameters, since they are also needed by
78
- // the HmrServer.
79
- // The whole bundling/serializing logic should follow as well.
80
64
  this._createModuleId = config.serializer.createModuleIdFactory();
81
65
  this._bundler = new IncrementalBundler(config, {
82
66
  hasReducedPerformance: options && options.hasReducedPerformance,
@@ -255,19 +239,12 @@ class Server {
255
239
  });
256
240
  }
257
241
  async getOrderedDependencyPaths(options) {
258
- const {
259
- entryFile,
260
- onProgress,
261
- resolverOptions,
262
- transformOptions,
263
- /* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses an
264
- * error found when Flow v0.122.0 was deployed. To see the error, delete
265
- * this comment and run Flow. */
266
- } = splitBundleOptions({
267
- ...Server.DEFAULT_BUNDLE_OPTIONS,
268
- ...options,
269
- bundleType: "bundle",
270
- });
242
+ const { entryFile, onProgress, resolverOptions, transformOptions } =
243
+ splitBundleOptions({
244
+ ...Server.DEFAULT_BUNDLE_OPTIONS,
245
+ ...options,
246
+ bundleType: "bundle",
247
+ });
271
248
  const { prepend, graph } = await this._bundler.buildGraph(
272
249
  entryFile,
273
250
  transformOptions,
@@ -281,8 +258,6 @@ class Server {
281
258
  const platform =
282
259
  transformOptions.platform ||
283
260
  parsePlatformFilePath(entryFile, this._platforms).platform;
284
-
285
- // $FlowFixMe[incompatible-return]
286
261
  return await getAllFiles(prepend, graph, {
287
262
  platform,
288
263
  processModuleFilter: this._config.serializer.processModuleFilter,
@@ -339,8 +314,6 @@ class Server {
339
314
  urlObj.query.platform,
340
315
  this._config.resolver.assetExts
341
316
  );
342
- // Tell clients to cache this for 1 year.
343
- // This is safe as the asset url contains a hash of the asset.
344
317
  if (process.env.REACT_NATIVE_ENABLE_ASSET_CACHING === true) {
345
318
  res.setHeader("Cache-Control", "max-age=31536000");
346
319
  }
@@ -395,7 +368,6 @@ class Server {
395
368
  this._serverOptions.onBundleBuilt(pathname);
396
369
  }
397
370
  } else if (pathname.endsWith(".map")) {
398
- // Chrome dev tools may need to access the source maps.
399
371
  res.setHeader("Access-Control-Allow-Origin", "devtools://devtools");
400
372
  await this._processSourceMapRequest(
401
373
  req,
@@ -446,11 +418,6 @@ class Server {
446
418
  serializerOptions,
447
419
  transformOptions,
448
420
  } = splitBundleOptions(bundleOptions);
449
-
450
- /**
451
- * `entryFile` is relative to projectRoot, we need to use resolution function
452
- * to find the appropriate file with supported extensions.
453
- */
454
421
  let resolvedEntryFilePath;
455
422
  try {
456
423
  resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
@@ -474,8 +441,6 @@ class Server {
474
441
  shallow: graphOptions.shallow,
475
442
  lazy: graphOptions.lazy,
476
443
  });
477
-
478
- // For resources that support deletion, handle the DELETE method.
479
444
  if (deleteFn && req.method === "DELETE") {
480
445
  const deleteContext = {
481
446
  graphId,
@@ -503,11 +468,6 @@ class Server {
503
468
  (transformedFileCount / totalFileCount) * 100,
504
469
  10
505
470
  );
506
-
507
- // We want to throttle the updates so that we only show meaningful
508
- // UI updates slow enough for the client to actually handle them. For
509
- // that, we check the percentage, and only send percentages that are
510
- // actually different and that have increased from the last one we sent.
511
471
  if (currentProgress > lastProgress || totalFileCount < 10) {
512
472
  if (mres instanceof MultipartResponse) {
513
473
  mres.writeChunk(
@@ -520,14 +480,6 @@ class Server {
520
480
  })
521
481
  );
522
482
  }
523
-
524
- // The `uncork` called internally in Node via `promise.nextTick()` may not fire
525
- // until all of the Promises are resolved because the microtask queue we're
526
- // in could be starving the event loop. This can cause a bug where the progress
527
- // is not actually sent in the response until after bundling is complete. This
528
- // would defeat the purpose of sending progress, so we `uncork` the stream now
529
- // which will force the response to flush to the client immediately.
530
- // $FlowFixMe[method-unbinding] added when improving typing for this parameters
531
483
  if (res.socket != null && res.socket.uncork != null) {
532
484
  res.socket.uncork();
533
485
  }
@@ -614,9 +566,6 @@ class Server {
614
566
  type: "bundle_build_done",
615
567
  });
616
568
  log(
617
- /* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses
618
- * an error found when Flow v0.122.0 was deployed. To see the error,
619
- * delete this comment and run Flow. */
620
569
  createActionEndEntry({
621
570
  ...logEntry,
622
571
  ...createEndEntry(endContext),
@@ -751,9 +700,6 @@ class Server {
751
700
  bundlePerfLogger.end("SUCCESS");
752
701
  });
753
702
  if (
754
- // We avoid parsing the dates since the client should never send a more
755
- // recent date than the one returned by the Delta Bundler (if that's the
756
- // case it's fine to return the whole bundle).
757
703
  req.headers["if-modified-since"] ===
758
704
  result.lastModifiedDate.toUTCString()
759
705
  ) {
@@ -794,16 +740,11 @@ class Server {
794
740
  res.end();
795
741
  },
796
742
  });
797
-
798
- // This function ensures that modules in source maps are sorted in the same
799
- // order as in a plain JS bundle.
800
743
  _getSortedModules(graph) {
801
744
  const modules = [...graph.dependencies.values()];
802
- // Assign IDs to modules in a consistent order
803
745
  for (const module of modules) {
804
746
  this._createModuleId(module.path);
805
747
  }
806
- // Sort by IDs
807
748
  return modules.sort(
808
749
  (a, b) => this._createModuleId(a.path) - this._createModuleId(b.path)
809
750
  );
@@ -926,8 +867,6 @@ class Server {
926
867
  content: codeFrameColumns(
927
868
  fs.readFileSync(fileAbsolute, "utf8"),
928
869
  {
929
- // Metro returns 0 based columns but codeFrameColumns expects 1-based columns
930
- // $FlowFixMe[unsafe-addition]
931
870
  start: {
932
871
  column: column + 1,
933
872
  line: lineNumber,
@@ -954,7 +893,6 @@ class Server {
954
893
  createActionStartEntry("Symbolicating")
955
894
  );
956
895
  debug("Start symbolication");
957
- /* $FlowFixMe: where is `rawBody` defined? Is it added by the `connect` framework? */
958
896
  const body = await req.rawBody;
959
897
  const parsedBody = JSON.parse(body);
960
898
  const rewriteAndNormalizeStackFrame = (frame, lineNumber) => {
@@ -974,12 +912,9 @@ class Server {
974
912
  return frame;
975
913
  };
976
914
  const stack = parsedBody.stack.map(rewriteAndNormalizeStackFrame);
977
- // In case of multiple bundles / HMR, some stack frames can have different URLs from others
978
915
  const urls = new Set();
979
916
  stack.forEach((frame) => {
980
- // These urls have been rewritten and normalized above.
981
917
  const sourceUrl = frame.file;
982
- // Skip `/debuggerWorker.js` which does not need symbolication.
983
918
  if (
984
919
  sourceUrl != null &&
985
920
  !urls.has(sourceUrl) &&
@@ -1033,11 +968,6 @@ class Server {
1033
968
  serializerOptions,
1034
969
  transformOptions,
1035
970
  } = splitBundleOptions(bundleOptions);
1036
-
1037
- /**
1038
- * `entryFile` is relative to projectRoot, we need to use resolution function
1039
- * to find the appropriate file with supported extensions.
1040
- */
1041
971
  const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
1042
972
  relativeTo: "server",
1043
973
  resolverOptions,
@@ -1134,25 +1064,18 @@ class Server {
1134
1064
  _getEntryPointAbsolutePath(entryFile) {
1135
1065
  return path.resolve(this._getServerRootDir(), entryFile);
1136
1066
  }
1137
-
1138
- // Wait for the server to finish initializing.
1139
1067
  async ready() {
1140
1068
  await this._bundler.ready();
1141
1069
  }
1142
1070
  _shouldAddModuleToIgnoreList(module) {
1143
- // TODO: Add flag to Module signifying whether it represents generated code
1144
- // and clean up these heuristics.
1145
1071
  return (
1146
- // Prelude code, see getPrependedScripts.js
1147
1072
  module.path === "__prelude__" ||
1148
- // Generated require.context() module, see contextModule.js
1149
1073
  module.path.includes("?ctx=") ||
1150
1074
  this._config.serializer.isThirdPartyModule(module)
1151
1075
  );
1152
1076
  }
1153
1077
  }
1154
1078
  function* zip(xs, ys) {
1155
- //$FlowIssue #9324959
1156
1079
  const ysIter = ys[Symbol.iterator]();
1157
1080
  for (const x of xs) {
1158
1081
  const y = ysIter.next();
@@ -8,17 +8,6 @@ var _querystring = _interopRequireDefault(require("querystring"));
8
8
  function _interopRequireDefault(obj) {
9
9
  return obj && obj.__esModule ? obj : { default: obj };
10
10
  }
11
- /**
12
- * Copyright (c) Meta Platforms, Inc. and affiliates.
13
- *
14
- * This source code is licensed under the MIT license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- *
17
- *
18
- * @format
19
- * @oncall react_native
20
- */
21
-
22
11
  function coerceKeyValueArray(keyValueArray) {
23
12
  const result = Object.create(null);
24
13
  for (const item of keyValueArray) {
package/src/cli-utils.js CHANGED
@@ -1,14 +1,3 @@
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
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
3
  const fs = require("fs");
package/src/cli.js CHANGED
@@ -1,22 +1,9 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- *
9
- * @format
10
- * @oncall react_native
11
- */
12
2
  "use strict";
13
3
 
14
4
  try {
15
- // $FlowFixMe[untyped-import]
16
5
  require("metro-babel-register").unstable_registerForMetroMonorepo();
17
6
  } catch {}
18
7
  const { attachMetroCli } = require("./index");
19
8
  const yargs = require("yargs");
20
-
21
- // $FlowFixMe[unused-promise]
22
9
  attachMetroCli(yargs.demandCommand(1)).argv;
@@ -6,17 +6,6 @@ var _parseKeyValueParamArray = _interopRequireDefault(
6
6
  function _interopRequireDefault(obj) {
7
7
  return obj && obj.__esModule ? obj : { default: obj };
8
8
  }
9
- /**
10
- * Copyright (c) Meta Platforms, Inc. and affiliates.
11
- *
12
- * This source code is licensed under the MIT license found in the
13
- * LICENSE file in the root directory of this source tree.
14
- *
15
- *
16
- * @format
17
- * @oncall react_native
18
- */
19
-
20
9
  const { makeAsyncCommand } = require("../cli-utils");
21
10
  const TerminalReporter = require("../lib/TerminalReporter");
22
11
  const { loadConfig } = require("metro-config");
@@ -85,8 +74,6 @@ module.exports = () => ({
85
74
  describe:
86
75
  "Custom resolver options of the form key=value. URL-encoded. May be specified multiple times.",
87
76
  });
88
-
89
- // Deprecated
90
77
  yargs.option("reset-cache", {
91
78
  type: "boolean",
92
79
  });
@@ -104,8 +91,6 @@ module.exports = () => ({
104
91
  customResolverOptions: argv.resolverOption,
105
92
  customTransformOptions: argv.transformOption,
106
93
  };
107
-
108
- // Inline require() to avoid circular dependency with ../index
109
94
  const MetroApi = require("../index");
110
95
  await MetroApi.runBuild(config, {
111
96
  ...options,
@@ -1,14 +1,3 @@
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
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
3
  const { makeAsyncCommand } = require("../cli-utils");
@@ -24,8 +13,6 @@ async function dependencies(args, config) {
24
13
  new Error(`File ${rootModuleAbsolutePath} does not exist`)
25
14
  );
26
15
  }
27
-
28
- // $FlowFixMe[cannot-write]
29
16
  config.cacheStores = [];
30
17
  const relativePath = path.relative(
31
18
  config.server.unstable_serverRoot ?? config.projectRoot,
@@ -43,10 +30,6 @@ async function dependencies(args, config) {
43
30
  const server = new Server(config);
44
31
  const deps = await server.getOrderedDependencyPaths(options);
45
32
  deps.forEach((modulePath) => {
46
- // Temporary hack to disable listing dependencies not under this directory.
47
- // Long term, we need either
48
- // (a) JS code to not depend on anything outside this directory, or
49
- // (b) Come up with a way to declare this dependency in Buck.
50
33
  const isInsideProjectRoots =
51
34
  config.watchFolders.filter((root) => modulePath.startsWith(root)).length >
52
35
  0;
@@ -56,8 +39,7 @@ async function dependencies(args, config) {
56
39
  });
57
40
  server.end();
58
41
  return args.output != null
59
- ? // $FlowFixMe[method-unbinding]
60
- promisify(outStream.end).bind(outStream)()
42
+ ? promisify(outStream.end).bind(outStream)()
61
43
  : Promise.resolve();
62
44
  }
63
45
  module.exports = () => ({
@@ -1,14 +1,3 @@
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
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
3
  const { makeAsyncCommand, watchFile } = require("../cli-utils");
@@ -63,13 +52,9 @@ module.exports = () => ({
63
52
  alias: "c",
64
53
  type: "string",
65
54
  });
66
-
67
- // Deprecated
68
55
  yargs.option("reset-cache", {
69
56
  type: "boolean",
70
57
  });
71
-
72
- // Examples
73
58
  yargs.example(
74
59
  "secure-server-options",
75
60
  '-s.cert="$(cat path/to/cert)" -s.key="$(cat path/to/key")'
@@ -85,14 +70,10 @@ module.exports = () => ({
85
70
  restarting = true;
86
71
  }
87
72
  if (server) {
88
- // eslint-disable-next-line no-console
89
73
  console.log("Configuration changed. Restarting the server...");
90
- // $FlowFixMe[method-unbinding] added when improving typing for this parameters
91
74
  await promisify(server.close).call(server);
92
75
  }
93
76
  const config = await loadConfig(argv);
94
-
95
- // Inline require() to avoid circular dependency with ../index
96
77
  const MetroApi = require("../index");
97
78
  const {
98
79
  config: _config,
package/src/index.flow.js CHANGED
@@ -1,14 +1,3 @@
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
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
3
  const makeBuildCommand = require("./commands/build");
@@ -37,8 +26,6 @@ exports.Terminal = Terminal;
37
26
  exports.TerminalReporter = TerminalReporter;
38
27
  async function getConfig(config) {
39
28
  const defaultConfig = await getDefaultConfig(config.projectRoot);
40
- // $FlowFixMe[incompatible-variance]
41
- // $FlowFixMe[incompatible-call]
42
29
  return mergeConfig(defaultConfig, config);
43
30
  }
44
31
  async function runMetro(config, options) {
@@ -81,12 +68,8 @@ exports.loadConfig = loadConfig;
81
68
  exports.mergeConfig = mergeConfig;
82
69
  exports.resolveConfig = resolveConfig;
83
70
  const createConnectMiddleware = async function (config, options) {
84
- // $FlowFixMe[incompatible-variance]
85
- // $FlowFixMe[incompatible-call]
86
71
  const metroServer = await runMetro(config, options);
87
72
  let enhancedMiddleware = metroServer.processRequest;
88
-
89
- // Enhance the resulting middleware using the config options
90
73
  if (config.server.enhanceMiddleware) {
91
74
  enhancedMiddleware = config.server.enhanceMiddleware(
92
75
  enhancedMiddleware,
@@ -130,11 +113,8 @@ exports.runServer = async (
130
113
  onReady,
131
114
  secureServerOptions,
132
115
  secure,
133
- //deprecated
134
116
  secureCert,
135
- // deprecated
136
117
  secureKey,
137
- // deprecated
138
118
  unstable_extraMiddleware,
139
119
  waitForBundler = false,
140
120
  websocketEndpoints = {},
@@ -143,7 +123,6 @@ exports.runServer = async (
143
123
  ) => {
144
124
  await earlyPortCheck(host, config.server.port);
145
125
  if (secure != null || secureCert != null || secureKey != null) {
146
- // eslint-disable-next-line no-console
147
126
  console.warn(
148
127
  chalk.inverse.yellow.bold(" DEPRECATED "),
149
128
  "The `secure`, `secureCert`, and `secureKey` options are now deprecated. " +
@@ -151,7 +130,6 @@ exports.runServer = async (
151
130
  "Metro's https development server."
152
131
  );
153
132
  }
154
- // Lazy require
155
133
  const connect = require("connect");
156
134
  const serverApp = connect();
157
135
  const { middleware, end, metroServer } = await createConnectMiddleware(
@@ -176,7 +154,6 @@ exports.runServer = async (
176
154
  ...secureServerOptions,
177
155
  };
178
156
  }
179
- // $FlowFixMe[incompatible-call] 'http' and 'https' Flow types do not match
180
157
  httpServer = https.createServer(options, serverApp);
181
158
  } else {
182
159
  httpServer = http.createServer(serverApp);
@@ -220,10 +197,6 @@ exports.runServer = async (
220
197
  });
221
198
  resolve(httpServer);
222
199
  });
223
-
224
- // Disable any kind of automatic timeout behavior for incoming
225
- // requests in case it takes the packager more than the default
226
- // timeout of 120 seconds to respond to a request.
227
200
  httpServer.timeout = 0;
228
201
  httpServer.on("close", () => {
229
202
  end();
@@ -248,8 +221,6 @@ exports.runBuild = async (
248
221
  sourceMapUrl,
249
222
  }
250
223
  ) => {
251
- // $FlowFixMe[incompatible-variance]
252
- // $FlowFixMe[incompatible-call]
253
224
  const metroServer = await runMetro(config, {
254
225
  watch: false,
255
226
  });
@@ -283,8 +254,6 @@ exports.runBuild = async (
283
254
  dev,
284
255
  platform,
285
256
  };
286
-
287
- // eslint-disable-next-line no-console
288
257
  await output.save(metroBundle, outputOptions, console.log);
289
258
  }
290
259
  return metroBundle;
package/src/index.js CHANGED
@@ -1,19 +1,5 @@
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
- *
8
- * @format
9
- * @oncall react_native
10
- */
11
-
12
1
  "use strict";
13
2
 
14
- /*::
15
- export type * from './index.flow';
16
- */
17
3
  try {
18
4
  require("metro-babel-register").unstable_registerForMetroMonorepo();
19
5
  } catch {}
@@ -1,13 +1,3 @@
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
- *
9
- */
10
-
11
1
  "use strict";
12
2
 
13
3
  module.exports = {
@@ -1,13 +1,3 @@
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
- *
9
- */
10
-
11
1
  "use strict";
12
2
 
13
3
  const Foo = require("./Foo");
@@ -1,19 +1,7 @@
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
- *
9
- */
10
-
11
1
  "use strict";
12
2
 
13
- // Add a random require to fill the bundle with some sourcecode.
14
3
  require("./AssetRegistry");
15
4
  const calcSum = (value) => {
16
- // some random function
17
5
  const error = new Error("SOURCEMAP: value: " + value);
18
6
  return error;
19
7
  };
@@ -1,13 +1,3 @@
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
- *
9
- */
10
-
11
1
  "use strict";
12
2
 
13
3
  const asset = require("./test.png");
@@ -1,17 +1,5 @@
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
- *
9
- */
10
-
11
1
  "use strict";
12
2
 
13
- // $FlowFixMe[signature-verification-failure]
14
3
  var a = 2n;
15
- // $FlowFixMe[signature-verification-failure]
16
4
  var b = 3n;
17
5
  module.exports = a ** b;
@@ -1,18 +1,7 @@
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
- *
9
- */
10
-
11
1
  "use strict";
12
2
 
13
3
  const Bar = require("./Bar");
14
4
  const Foo = require("./Foo");
15
- // $FlowFixMe: Flow doesn't understand TypeScript
16
5
  const TypeScript = require("./TypeScript");
17
6
  Object.keys({
18
7
  ...Bar,
@@ -1,13 +1,3 @@
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
- *
9
- */
10
-
11
1
  "use strict";
12
2
 
13
3
  module.exports = global.POLYFILL_IS_INJECTED;
@@ -4,18 +4,4 @@ var _doesNotExist = _interopRequireDefault(require("./does-not-exist"));
4
4
  function _interopRequireDefault(obj) {
5
5
  return obj && obj.__esModule ? obj : { default: obj };
6
6
  }
7
- /**
8
- * Copyright (c) Meta Platforms, Inc. and affiliates.
9
- *
10
- * This source code is licensed under the MIT license found in the
11
- * LICENSE file in the root directory of this source tree.
12
- *
13
- *
14
- * @format
15
- */
16
-
17
- // $FlowExpectedError[cannot-resolve-module]
18
-
19
- // $FlowExpectedError[cannot-resolve-module]
20
-
21
7
  global.x = _doesNotExist.default;
@@ -1,18 +1,4 @@
1
1
  "use strict";
2
2
 
3
3
  var _doesNotExist = require("./does-not'\"-exist");
4
- /**
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- *
10
- *
11
- * @format
12
- */
13
-
14
- /* eslint-disable no-unused-vars */
15
-
16
- // $FlowExpectedError[cannot-resolve-module]
17
-
18
4
  global.x = _doesNotExist.aaaaaaaaaa;