metro 0.83.1 → 0.83.2

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 (206) hide show
  1. package/package.json +15 -15
  2. package/src/Assets.js +68 -42
  3. package/src/Assets.js.flow +13 -24
  4. package/src/Bundler/util.js +40 -17
  5. package/src/Bundler/util.js.flow +6 -13
  6. package/src/Bundler.js +17 -6
  7. package/src/Bundler.js.flow +3 -7
  8. package/src/DeltaBundler/DeltaCalculator.js +14 -10
  9. package/src/DeltaBundler/DeltaCalculator.js.flow +4 -7
  10. package/src/DeltaBundler/Graph.js +44 -35
  11. package/src/DeltaBundler/Graph.js.flow +3 -4
  12. package/src/DeltaBundler/Serializers/baseJSBundle.js +24 -10
  13. package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +6 -9
  14. package/src/DeltaBundler/Serializers/getAllFiles.js +9 -6
  15. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +4 -8
  16. package/src/DeltaBundler/Serializers/getAssets.js +18 -11
  17. package/src/DeltaBundler/Serializers/getAssets.js.flow +5 -9
  18. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +26 -0
  19. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +7 -6
  20. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +3 -9
  21. package/src/DeltaBundler/Serializers/getRamBundleInfo.js +40 -23
  22. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +11 -18
  23. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +4 -1
  24. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -5
  25. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +7 -4
  26. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +3 -7
  27. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +4 -1
  28. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +2 -6
  29. package/src/DeltaBundler/Serializers/helpers/js.js +65 -31
  30. package/src/DeltaBundler/Serializers/helpers/js.js.flow +21 -21
  31. package/src/DeltaBundler/Serializers/helpers/processModules.js +8 -5
  32. package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -7
  33. package/src/DeltaBundler/Serializers/hmrJSBundle.js +70 -25
  34. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +43 -33
  35. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +19 -16
  36. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -14
  37. package/src/DeltaBundler/Serializers/sourceMapObject.js +12 -10
  38. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -9
  39. package/src/DeltaBundler/Serializers/sourceMapString.js +14 -12
  40. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +4 -9
  41. package/src/DeltaBundler/Transformer.js +31 -22
  42. package/src/DeltaBundler/Transformer.js.flow +10 -17
  43. package/src/DeltaBundler/Worker.flow.js +25 -18
  44. package/src/DeltaBundler/Worker.flow.js.flow +12 -18
  45. package/src/DeltaBundler/Worker.js.flow +2 -0
  46. package/src/DeltaBundler/WorkerFarm.js +13 -11
  47. package/src/DeltaBundler/WorkerFarm.js.flow +7 -9
  48. package/src/DeltaBundler/buildSubgraph.js +12 -12
  49. package/src/DeltaBundler/buildSubgraph.js.flow +1 -1
  50. package/src/DeltaBundler/getTransformCacheKey.js +12 -6
  51. package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -7
  52. package/src/DeltaBundler/mergeDeltas.js +4 -1
  53. package/src/DeltaBundler/mergeDeltas.js.flow +5 -6
  54. package/src/DeltaBundler/types.d.ts +4 -1
  55. package/src/DeltaBundler/{types.flow.js.flow → types.js.flow} +5 -3
  56. package/src/DeltaBundler.js +15 -6
  57. package/src/DeltaBundler.js.flow +4 -8
  58. package/src/HmrServer.js +116 -68
  59. package/src/HmrServer.js.flow +41 -52
  60. package/src/IncrementalBundler/GraphNotFoundError.js +5 -1
  61. package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -5
  62. package/src/IncrementalBundler/ResourceNotFoundError.js +5 -1
  63. package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -5
  64. package/src/IncrementalBundler/RevisionNotFoundError.js +5 -1
  65. package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -5
  66. package/src/IncrementalBundler.js +71 -35
  67. package/src/IncrementalBundler.js.flow +12 -16
  68. package/src/ModuleGraph/test-helpers.js +19 -14
  69. package/src/ModuleGraph/worker/JsFileWrapping.js +19 -18
  70. package/src/ModuleGraph/worker/JsFileWrapping.js.flow +1 -10
  71. package/src/ModuleGraph/worker/collectDependencies.js +81 -52
  72. package/src/ModuleGraph/worker/collectDependencies.js.flow +15 -22
  73. package/src/ModuleGraph/worker/generateImportNames.js +12 -6
  74. package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -7
  75. package/src/ModuleGraph/worker/importLocationsPlugin.js +5 -4
  76. package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +2 -4
  77. package/src/Server/MultipartResponse.js +11 -4
  78. package/src/Server/MultipartResponse.js.flow +2 -5
  79. package/src/Server/symbolicate.d.ts +31 -0
  80. package/src/Server/symbolicate.js +15 -16
  81. package/src/Server/symbolicate.js.flow +6 -16
  82. package/src/Server.d.ts +0 -1
  83. package/src/Server.js +298 -191
  84. package/src/Server.js.flow +136 -99
  85. package/src/cli-utils.js +13 -4
  86. package/src/cli-utils.js.flow +3 -5
  87. package/src/cli.js.flow +2 -0
  88. package/src/commands/build.js +17 -10
  89. package/src/commands/build.js.flow +6 -6
  90. package/src/commands/dependencies.js +26 -16
  91. package/src/commands/dependencies.js.flow +7 -9
  92. package/src/commands/serve.js +16 -11
  93. package/src/commands/serve.js.flow +5 -6
  94. package/src/index.d.ts +26 -3
  95. package/src/index.flow.js +162 -72
  96. package/src/index.flow.js.flow +60 -47
  97. package/src/index.js.flow +2 -0
  98. package/src/integration_tests/basic_bundle/TestBundle.js.flow +2 -1
  99. package/src/integration_tests/basic_bundle/import-export/index.js +2 -2
  100. package/src/integration_tests/basic_bundle/require-context/mode-eager.js +2 -2
  101. package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js +2 -2
  102. package/src/integration_tests/basic_bundle/require-context/mode-lazy.js +2 -2
  103. package/src/integration_tests/basic_bundle/require-context/mode-sync.js +1 -1
  104. package/src/integration_tests/basic_bundle/require-context/utils.js +1 -1
  105. package/src/integration_tests/execBundle.js +7 -4
  106. package/src/integration_tests/execBundle.js.flow +1 -3
  107. package/src/integration_tests/metro.config.js +3 -3
  108. package/src/lib/BatchProcessor.js +15 -5
  109. package/src/lib/BatchProcessor.js.flow +2 -6
  110. package/src/lib/CountingSet.js.flow +2 -2
  111. package/src/lib/JsonReporter.js +6 -2
  112. package/src/lib/JsonReporter.js.flow +1 -5
  113. package/src/lib/RamBundleParser.js +12 -3
  114. package/src/lib/RamBundleParser.js.flow +2 -6
  115. package/src/lib/TerminalReporter.js +95 -56
  116. package/src/lib/TerminalReporter.js.flow +9 -12
  117. package/src/lib/bundleToString.js +4 -1
  118. package/src/lib/bundleToString.js.flow +2 -9
  119. package/src/lib/contextModule.js +2 -2
  120. package/src/lib/contextModuleTemplates.js +7 -13
  121. package/src/lib/countLines.js +5 -1
  122. package/src/lib/countLines.js.flow +1 -3
  123. package/src/lib/createWebsocketServer.js +6 -2
  124. package/src/lib/createWebsocketServer.js.flow +4 -4
  125. package/src/lib/debounceAsyncQueue.js +4 -1
  126. package/src/lib/debounceAsyncQueue.js.flow +1 -5
  127. package/src/lib/formatBundlingError.js +32 -22
  128. package/src/lib/formatBundlingError.js.flow +18 -20
  129. package/src/lib/getAppendScripts.js +19 -15
  130. package/src/lib/getAppendScripts.js.flow +9 -13
  131. package/src/lib/getGraphId.js +12 -6
  132. package/src/lib/getGraphId.js.flow +4 -10
  133. package/src/lib/getPreludeCode.js +7 -10
  134. package/src/lib/getPreludeCode.js.flow +2 -6
  135. package/src/lib/getPrependedScripts.js +39 -11
  136. package/src/lib/getPrependedScripts.js.flow +8 -13
  137. package/src/lib/isResolvedDependency.js.flow +1 -1
  138. package/src/lib/logToConsole.js +18 -12
  139. package/src/lib/logToConsole.js.flow +5 -14
  140. package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +144 -0
  141. package/src/lib/parseBundleOptionsFromBundleRequestUrl.js.flow +146 -0
  142. package/src/lib/parseCustomResolverOptions.js +8 -6
  143. package/src/lib/parseCustomResolverOptions.js.flow +6 -12
  144. package/src/lib/parseCustomTransformOptions.js +8 -6
  145. package/src/lib/parseCustomTransformOptions.js.flow +11 -14
  146. package/src/lib/parseJsonBody.js +4 -1
  147. package/src/lib/parseJsonBody.js.flow +1 -3
  148. package/src/lib/pathUtils.js +34 -0
  149. package/src/lib/pathUtils.js.flow +16 -0
  150. package/src/lib/relativizeSourceMap.js +12 -3
  151. package/src/lib/relativizeSourceMap.js.flow +2 -6
  152. package/src/lib/reporting.js +25 -19
  153. package/src/lib/reporting.js.flow +6 -16
  154. package/src/lib/splitBundleOptions.js +4 -2
  155. package/src/lib/splitBundleOptions.js.flow +4 -7
  156. package/src/lib/transformHelpers.js +18 -20
  157. package/src/lib/transformHelpers.js.flow +5 -15
  158. package/src/node-haste/DependencyGraph/ModuleResolution.js +75 -57
  159. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +28 -44
  160. package/src/node-haste/DependencyGraph/createFileMap.js +13 -7
  161. package/src/node-haste/DependencyGraph/createFileMap.js.flow +2 -5
  162. package/src/node-haste/DependencyGraph.js +61 -45
  163. package/src/node-haste/DependencyGraph.js.flow +34 -31
  164. package/src/node-haste/Package.js +13 -6
  165. package/src/node-haste/Package.js.flow +3 -7
  166. package/src/node-haste/{ModuleCache.js → PackageCache.js} +11 -19
  167. package/src/node-haste/{ModuleCache.js.flow → PackageCache.js.flow} +2 -30
  168. package/src/node-haste/lib/AssetPaths.js +14 -8
  169. package/src/node-haste/lib/AssetPaths.js.flow +7 -8
  170. package/src/node-haste/lib/parsePlatformFilePath.js +10 -4
  171. package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -6
  172. package/src/shared/output/RamBundle/as-assets.js +42 -22
  173. package/src/shared/output/RamBundle/as-assets.js.flow +12 -15
  174. package/src/shared/output/RamBundle/as-indexed-file.js +33 -23
  175. package/src/shared/output/RamBundle/as-indexed-file.js.flow +10 -16
  176. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +11 -10
  177. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -6
  178. package/src/shared/output/RamBundle/magic-number.js +5 -1
  179. package/src/shared/output/RamBundle/magic-number.js.flow +1 -3
  180. package/src/shared/output/RamBundle/util.js +20 -13
  181. package/src/shared/output/RamBundle/util.js.flow +4 -6
  182. package/src/shared/output/RamBundle/write-sourcemap.js +9 -3
  183. package/src/shared/output/RamBundle/write-sourcemap.js.flow +2 -6
  184. package/src/shared/output/RamBundle.js +16 -9
  185. package/src/shared/output/RamBundle.js.flow +8 -12
  186. package/src/shared/output/bundle.flow.js +37 -13
  187. package/src/shared/output/bundle.flow.js.flow +24 -12
  188. package/src/shared/output/bundle.js.flow +2 -0
  189. package/src/shared/output/meta.js +16 -9
  190. package/src/shared/output/meta.js.flow +3 -5
  191. package/src/shared/output/unbundle.js +14 -1
  192. package/src/shared/output/unbundle.js.flow +1 -3
  193. package/src/shared/output/writeFile.js +11 -4
  194. package/src/shared/output/writeFile.js.flow +3 -5
  195. package/src/shared/types.d.ts +0 -1
  196. package/src/shared/{types.flow.js.flow → types.js.flow} +16 -17
  197. package/src/lib/createModuleIdFactory.js +0 -15
  198. package/src/lib/createModuleIdFactory.js.flow +0 -27
  199. package/src/lib/getMaxWorkers.js +0 -9
  200. package/src/lib/getMaxWorkers.js.flow +0 -22
  201. package/src/lib/parseOptionsFromUrl.js +0 -62
  202. package/src/lib/parseOptionsFromUrl.js.flow +0 -97
  203. package/src/node-haste/Module.js +0 -20
  204. package/src/node-haste/Module.js.flow +0 -41
  205. /package/src/DeltaBundler/{types.flow.js → types.js} +0 -0
  206. /package/src/shared/{types.flow.js → types.js} +0 -0
@@ -9,17 +9,16 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- 'use strict';
13
-
14
- import type {DeltaResult, Options} from './types.flow';
12
+ import type {DeltaResult, Options} from './types';
15
13
  import type {RootPerfLogger} from 'metro-config';
16
14
  import type {ChangeEvent} from 'metro-file-map';
17
15
 
18
16
  import {Graph} from './Graph';
17
+ import EventEmitter from 'events';
19
18
  import path from 'path';
20
19
 
20
+ // eslint-disable-next-line import/no-commonjs
21
21
  const debug = require('debug')('Metro:DeltaCalculator');
22
- const {EventEmitter} = require('events');
23
22
 
24
23
  /**
25
24
  * This class is in charge of calculating the delta of changed modules that
@@ -27,7 +26,7 @@ const {EventEmitter} = require('events');
27
26
  * traverse the files that have been changed between calls and avoid having to
28
27
  * traverse the whole dependency tree for trivial small changes.
29
28
  */
30
- class DeltaCalculator<T> extends EventEmitter {
29
+ export default class DeltaCalculator<T> extends EventEmitter {
31
30
  _changeEventSource: EventEmitter;
32
31
  _options: Options<T>;
33
32
 
@@ -324,5 +323,3 @@ class DeltaCalculator<T> extends EventEmitter {
324
323
  };
325
324
  }
326
325
  }
327
-
328
- module.exports = DeltaCalculator;
@@ -8,11 +8,11 @@ var _contextModule = require("../lib/contextModule");
8
8
  var _CountingSet = _interopRequireDefault(require("../lib/CountingSet"));
9
9
  var _isResolvedDependency = require("../lib/isResolvedDependency");
10
10
  var _buildSubgraph = require("./buildSubgraph");
11
+ var _invariant = _interopRequireDefault(require("invariant"));
12
+ var _nullthrows = _interopRequireDefault(require("nullthrows"));
11
13
  function _interopRequireDefault(e) {
12
14
  return e && e.__esModule ? e : { default: e };
13
15
  }
14
- const invariant = require("invariant");
15
- const nullthrows = require("nullthrows");
16
16
  function getInternalOptions({ transform, resolve, onProgress, lazy, shallow }) {
17
17
  let numProcessed = 0;
18
18
  let total = 0;
@@ -44,7 +44,7 @@ class Graph {
44
44
  async traverseDependencies(paths, options) {
45
45
  const internalOptions = getInternalOptions(options);
46
46
  const modifiedPathsInBaseGraph = new Set(
47
- paths.filter((path) => this.dependencies.has(path))
47
+ paths.filter((path) => this.dependencies.has(path)),
48
48
  );
49
49
  const allModifiedPaths = new Set(paths);
50
50
  const delta = await this._buildDelta(
@@ -52,13 +52,15 @@ class Graph {
52
52
  internalOptions,
53
53
  (absolutePath) =>
54
54
  !this.dependencies.has(absolutePath) ||
55
- allModifiedPaths.has(absolutePath)
55
+ allModifiedPaths.has(absolutePath),
56
56
  );
57
57
  if (delta.errors.size > 0) {
58
58
  for (const modified of modifiedPathsInBaseGraph) {
59
59
  delta.baseModuleData.set(
60
60
  modified,
61
- this._moduleSnapshot(nullthrows(this.dependencies.get(modified)))
61
+ this._moduleSnapshot(
62
+ (0, _nullthrows.default)(this.dependencies.get(modified)),
63
+ ),
62
64
  );
63
65
  }
64
66
  }
@@ -100,15 +102,15 @@ class Graph {
100
102
  this._recursivelyCommitModule(modified, rollbackDelta, internalOptions);
101
103
  }
102
104
  this._collectCycles(delta, internalOptions);
103
- invariant(
105
+ (0, _invariant.default)(
104
106
  rollbackDelta.added.size === 0 && rollbackDelta.deleted.size === 0,
105
- "attempted to roll back a graph commit but there were still changes"
107
+ "attempted to roll back a graph commit but there were still changes",
106
108
  );
107
109
  throw error;
108
110
  }
109
111
  const added = new Map();
110
112
  for (const path of delta.added) {
111
- added.set(path, nullthrows(this.dependencies.get(path)));
113
+ added.set(path, (0, _nullthrows.default)(this.dependencies.get(path)));
112
114
  }
113
115
  const modified = new Map();
114
116
  for (const path of modifiedPathsInBaseGraph) {
@@ -117,7 +119,10 @@ class Graph {
117
119
  !delta.deleted.has(path) &&
118
120
  !delta.added.has(path)
119
121
  ) {
120
- modified.set(path, nullthrows(this.dependencies.get(path)));
122
+ modified.set(
123
+ path,
124
+ (0, _nullthrows.default)(this.dependencies.get(path)),
125
+ );
121
126
  }
122
127
  }
123
128
  return {
@@ -128,9 +133,9 @@ class Graph {
128
133
  }
129
134
  async initialTraverseDependencies(options) {
130
135
  const internalOptions = getInternalOptions(options);
131
- invariant(
136
+ (0, _invariant.default)(
132
137
  this.dependencies.size === 0,
133
- "initialTraverseDependencies called on nonempty graph"
138
+ "initialTraverseDependencies called on nonempty graph",
134
139
  );
135
140
  this.#gc.color.clear();
136
141
  this.#gc.possibleCycleRoots.clear();
@@ -172,7 +177,7 @@ class Graph {
172
177
  }
173
178
  return moduleFilter == null || moduleFilter(dependency.absolutePath);
174
179
  },
175
- }
180
+ },
176
181
  );
177
182
  return {
178
183
  added: new Set(),
@@ -189,14 +194,14 @@ class Graph {
189
194
  options,
190
195
  commitOptions = {
191
196
  onlyRemove: false,
192
- }
197
+ },
193
198
  ) {
194
199
  if (delta.errors.has(path)) {
195
200
  throw delta.errors.get(path);
196
201
  }
197
202
  const previousModule = this.dependencies.get(path);
198
- const currentModule = nullthrows(
199
- delta.updatedModuleData.get(path) ?? delta.baseModuleData.get(path)
203
+ const currentModule = (0, _nullthrows.default)(
204
+ delta.updatedModuleData.get(path) ?? delta.baseModuleData.get(path),
200
205
  );
201
206
  const previousDependencies = previousModule?.dependencies ?? new Map();
202
207
  const {
@@ -246,7 +251,7 @@ class Graph {
246
251
  curDependency,
247
252
  resolvedContexts.get(key),
248
253
  delta,
249
- options
254
+ options,
250
255
  );
251
256
  }
252
257
  }
@@ -255,7 +260,7 @@ class Graph {
255
260
  const dependencyKeysChangedOrReordered =
256
261
  currentDependencies.size !== previousDependencies.size ||
257
262
  [...currentDependencies.keys()].some(
258
- (currentKey, index) => currentKey !== previousDependencyKeys[index]
263
+ (currentKey, index) => currentKey !== previousDependencyKeys[index],
259
264
  );
260
265
  if (
261
266
  previousModule != null &&
@@ -271,9 +276,9 @@ class Graph {
271
276
  if (commitOptions.onlyRemove) {
272
277
  return nextModule;
273
278
  }
274
- invariant(
279
+ (0, _invariant.default)(
275
280
  nextModule.dependencies.size === currentDependencies.size,
276
- "Failed to add the correct dependencies"
281
+ "Failed to add the correct dependencies",
277
282
  );
278
283
  nextModule.dependencies = new Map(currentDependencies);
279
284
  return nextModule;
@@ -284,7 +289,7 @@ class Graph {
284
289
  dependency,
285
290
  requireContext,
286
291
  delta,
287
- options
292
+ options,
288
293
  ) {
289
294
  if (options.shallow) {
290
295
  } else if (!(0, _isResolvedDependency.isResolvedDependency)(dependency)) {
@@ -369,7 +374,7 @@ class Graph {
369
374
  const mainModule = this.dependencies.get(entryPoint);
370
375
  if (!mainModule) {
371
376
  throw new ReferenceError(
372
- "Module not registered in graph: " + entryPoint
377
+ "Module not registered in graph: " + entryPoint,
373
378
  );
374
379
  }
375
380
  this._reorderDependencies(mainModule, orderedDependencies, options);
@@ -412,12 +417,12 @@ class Graph {
412
417
  }
413
418
  _decrementImportBundleReference(dependency, parentModule) {
414
419
  const { absolutePath } = dependency;
415
- const importBundleNode = nullthrows(
416
- this.#importBundleNodes.get(absolutePath)
420
+ const importBundleNode = (0, _nullthrows.default)(
421
+ this.#importBundleNodes.get(absolutePath),
417
422
  );
418
- invariant(
423
+ (0, _invariant.default)(
419
424
  importBundleNode.inverseDependencies.has(parentModule.path),
420
- "lazy: import bundle inverse references"
425
+ "lazy: import bundle inverse references",
421
426
  );
422
427
  importBundleNode.inverseDependencies.delete(parentModule.path);
423
428
  if (importBundleNode.inverseDependencies.size === 0) {
@@ -435,7 +440,9 @@ class Graph {
435
440
  ) {
436
441
  continue;
437
442
  }
438
- yield nullthrows(this.dependencies.get(dependency.absolutePath));
443
+ yield (0, _nullthrows.default)(
444
+ this.dependencies.get(dependency.absolutePath),
445
+ );
439
446
  }
440
447
  }
441
448
  _moduleSnapshot(module) {
@@ -447,7 +454,7 @@ class Graph {
447
454
  continue;
448
455
  }
449
456
  const resolvedContext = this.#resolvedContexts.get(
450
- dependency.absolutePath
457
+ dependency.absolutePath,
451
458
  );
452
459
  if (resolvedContext != null) {
453
460
  resolvedContexts.set(key, resolvedContext);
@@ -496,8 +503,8 @@ class Graph {
496
503
  }
497
504
  _collectCycles(delta, options) {
498
505
  for (const path of this.#gc.possibleCycleRoots) {
499
- const module = nullthrows(this.dependencies.get(path));
500
- const color = nullthrows(this.#gc.color.get(path));
506
+ const module = (0, _nullthrows.default)(this.dependencies.get(path));
507
+ const color = (0, _nullthrows.default)(this.#gc.color.get(path));
501
508
  if (color === "purple") {
502
509
  this._markGray(module, options);
503
510
  } else {
@@ -512,17 +519,17 @@ class Graph {
512
519
  }
513
520
  }
514
521
  for (const path of this.#gc.possibleCycleRoots) {
515
- const module = nullthrows(this.dependencies.get(path));
522
+ const module = (0, _nullthrows.default)(this.dependencies.get(path));
516
523
  this._scan(module, options);
517
524
  }
518
525
  for (const path of this.#gc.possibleCycleRoots) {
519
526
  this.#gc.possibleCycleRoots.delete(path);
520
- const module = nullthrows(this.dependencies.get(path));
527
+ const module = (0, _nullthrows.default)(this.dependencies.get(path));
521
528
  this._collectWhite(module, delta);
522
529
  }
523
530
  }
524
531
  _markGray(module, options) {
525
- const color = nullthrows(this.#gc.color.get(module.path));
532
+ const color = (0, _nullthrows.default)(this.#gc.color.get(module.path));
526
533
  if (color !== "gray") {
527
534
  this.#gc.color.set(module.path, "gray");
528
535
  for (const childModule of this._children(module, options)) {
@@ -532,7 +539,7 @@ class Graph {
532
539
  }
533
540
  }
534
541
  _scan(module, options) {
535
- const color = nullthrows(this.#gc.color.get(module.path));
542
+ const color = (0, _nullthrows.default)(this.#gc.color.get(module.path));
536
543
  if (color === "gray") {
537
544
  if (
538
545
  module.inverseDependencies.size > 0 ||
@@ -551,14 +558,16 @@ class Graph {
551
558
  this.#gc.color.set(module.path, "black");
552
559
  for (const childModule of this._children(module, options)) {
553
560
  childModule.inverseDependencies.add(module.path);
554
- const childColor = nullthrows(this.#gc.color.get(childModule.path));
561
+ const childColor = (0, _nullthrows.default)(
562
+ this.#gc.color.get(childModule.path),
563
+ );
555
564
  if (childColor !== "black") {
556
565
  this._scanBlack(childModule, options);
557
566
  }
558
567
  }
559
568
  }
560
569
  _collectWhite(module, delta) {
561
- const color = nullthrows(this.#gc.color.get(module.path));
570
+ const color = (0, _nullthrows.default)(this.#gc.color.get(module.path));
562
571
  if (color === "white" && !this.#gc.possibleCycleRoots.has(module.path)) {
563
572
  this.#gc.color.set(module.path, "black");
564
573
  for (const dependency of module.dependencies.values()) {
@@ -41,15 +41,14 @@ import type {
41
41
  Options,
42
42
  ResolvedDependency,
43
43
  TransformInputOptions,
44
- } from './types.flow';
44
+ } from './types';
45
45
 
46
46
  import {fileMatchesContext} from '../lib/contextModule';
47
47
  import CountingSet from '../lib/CountingSet';
48
48
  import {isResolvedDependency} from '../lib/isResolvedDependency';
49
49
  import {buildSubgraph} from './buildSubgraph';
50
-
51
- const invariant = require('invariant');
52
- const nullthrows = require('nullthrows');
50
+ import invariant from 'invariant';
51
+ import nullthrows from 'nullthrows';
53
52
 
54
53
  // TODO: Convert to a Flow enum
55
54
  type NodeColor =
@@ -1,7 +1,18 @@
1
1
  "use strict";
2
2
 
3
- const getAppendScripts = require("../../lib/getAppendScripts");
4
- const processModules = require("./helpers/processModules");
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = baseJSBundle;
7
+ var _getAppendScripts = _interopRequireDefault(
8
+ require("../../lib/getAppendScripts"),
9
+ );
10
+ var _processModules = _interopRequireDefault(
11
+ require("./helpers/processModules"),
12
+ );
13
+ function _interopRequireDefault(e) {
14
+ return e && e.__esModule ? e : { default: e };
15
+ }
5
16
  function baseJSBundle(entryPoint, preModules, graph, options) {
6
17
  for (const module of graph.dependencies.values()) {
7
18
  options.createModuleId(module.path);
@@ -18,17 +29,21 @@ function baseJSBundle(entryPoint, preModules, graph, options) {
18
29
  if (options.modulesOnly) {
19
30
  preModules = [];
20
31
  }
21
- const preCode = processModules(preModules, processModulesOptions)
32
+ const preCode = (0, _processModules.default)(
33
+ preModules,
34
+ processModulesOptions,
35
+ )
22
36
  .map(([_, code]) => code)
23
37
  .join("\n");
24
38
  const modules = [...graph.dependencies.values()].sort(
25
- (a, b) => options.createModuleId(a.path) - options.createModuleId(b.path)
39
+ (a, b) => options.createModuleId(a.path) - options.createModuleId(b.path),
26
40
  );
27
- const postCode = processModules(
28
- getAppendScripts(entryPoint, [...preModules, ...modules], {
41
+ const postCode = (0, _processModules.default)(
42
+ (0, _getAppendScripts.default)(entryPoint, [...preModules, ...modules], {
29
43
  asyncRequireModulePath: options.asyncRequireModulePath,
30
44
  createModuleId: options.createModuleId,
31
45
  getRunModuleStatement: options.getRunModuleStatement,
46
+ globalPrefix: options.globalPrefix,
32
47
  inlineSourceMap: options.inlineSourceMap,
33
48
  runBeforeMainModule: options.runBeforeMainModule,
34
49
  runModule: options.runModule,
@@ -37,17 +52,16 @@ function baseJSBundle(entryPoint, preModules, graph, options) {
37
52
  sourceUrl: options.sourceUrl,
38
53
  getSourceUrl: options.getSourceUrl,
39
54
  }),
40
- processModulesOptions
55
+ processModulesOptions,
41
56
  )
42
57
  .map(([_, code]) => code)
43
58
  .join("\n");
44
59
  return {
45
60
  pre: preCode,
46
61
  post: postCode,
47
- modules: processModules(
62
+ modules: (0, _processModules.default)(
48
63
  [...graph.dependencies.values()],
49
- processModulesOptions
64
+ processModulesOptions,
50
65
  ).map(([module, code]) => [options.createModuleId(module.path), code]),
51
66
  };
52
67
  }
53
- module.exports = baseJSBundle;
@@ -9,20 +9,18 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- 'use strict';
13
-
14
12
  import type {
15
13
  MixedOutput,
16
14
  Module,
17
15
  ReadOnlyGraph,
18
16
  SerializerOptions,
19
- } from '../types.flow';
20
- import type {Bundle} from 'metro-runtime/src/modules/types.flow';
17
+ } from '../types';
18
+ import type {Bundle} from 'metro-runtime/src/modules/types';
21
19
 
22
- const getAppendScripts = require('../../lib/getAppendScripts');
23
- const processModules = require('./helpers/processModules');
20
+ import getAppendScripts from '../../lib/getAppendScripts';
21
+ import processModules from './helpers/processModules';
24
22
 
25
- function baseJSBundle(
23
+ export default function baseJSBundle(
26
24
  entryPoint: string,
27
25
  preModules: $ReadOnlyArray<Module<>>,
28
26
  graph: ReadOnlyGraph<>,
@@ -61,6 +59,7 @@ function baseJSBundle(
61
59
  asyncRequireModulePath: options.asyncRequireModulePath,
62
60
  createModuleId: options.createModuleId,
63
61
  getRunModuleStatement: options.getRunModuleStatement,
62
+ globalPrefix: options.globalPrefix,
64
63
  inlineSourceMap: options.inlineSourceMap,
65
64
  runBeforeMainModule: options.runBeforeMainModule,
66
65
  runModule: options.runModule,
@@ -83,5 +82,3 @@ function baseJSBundle(
83
82
  ).map(([module, code]) => [options.createModuleId(module.path), code]),
84
83
  };
85
84
  }
86
-
87
- module.exports = baseJSBundle;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
 
3
- const { getAssetFiles } = require("../../Assets");
4
- const { getJsOutput, isJsModule } = require("./helpers/js");
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = getAllFiles;
7
+ var _Assets = require("../../Assets");
8
+ var _js = require("./helpers/js");
5
9
  async function getAllFiles(pre, graph, options) {
6
10
  const modules = graph.dependencies;
7
11
  const { processModuleFilter } = options;
@@ -12,11 +16,11 @@ async function getAllFiles(pre, graph, options) {
12
16
  }
13
17
  }
14
18
  for (const module of modules.values()) {
15
- if (!isJsModule(module) || !processModuleFilter(module)) {
19
+ if (!(0, _js.isJsModule)(module) || !processModuleFilter(module)) {
16
20
  continue;
17
21
  }
18
- if (getJsOutput(module).type === "js/module/asset") {
19
- promises.push(getAssetFiles(module.path, options.platform));
22
+ if ((0, _js.getJsOutput)(module).type === "js/module/asset") {
23
+ promises.push((0, _Assets.getAssetFiles)(module.path, options.platform));
20
24
  } else {
21
25
  promises.push([module.path]);
22
26
  }
@@ -28,4 +32,3 @@ async function getAllFiles(pre, graph, options) {
28
32
  }
29
33
  return output;
30
34
  }
31
- module.exports = getAllFiles;
@@ -9,19 +9,17 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- 'use strict';
12
+ import type {Module, ReadOnlyGraph} from '../types';
13
13
 
14
- import type {Module, ReadOnlyGraph} from '../types.flow';
15
-
16
- const {getAssetFiles} = require('../../Assets');
17
- const {getJsOutput, isJsModule} = require('./helpers/js');
14
+ import {getAssetFiles} from '../../Assets';
15
+ import {getJsOutput, isJsModule} from './helpers/js';
18
16
 
19
17
  type Options = {
20
18
  platform: ?string,
21
19
  +processModuleFilter: (module: Module<>) => boolean,
22
20
  };
23
21
 
24
- async function getAllFiles(
22
+ export default async function getAllFiles(
25
23
  pre: $ReadOnlyArray<Module<>>,
26
24
  graph: ReadOnlyGraph<>,
27
25
  options: Options,
@@ -58,5 +56,3 @@ async function getAllFiles(
58
56
 
59
57
  return output;
60
58
  }
61
-
62
- module.exports = getAllFiles;
@@ -1,29 +1,36 @@
1
1
  "use strict";
2
2
 
3
- const { getAssetData } = require("../../Assets");
4
- const { getJsOutput, isJsModule } = require("./helpers/js");
5
- const path = require("path");
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.default = getAssets;
7
+ var _Assets = require("../../Assets");
8
+ var _js = require("./helpers/js");
9
+ var _path = _interopRequireDefault(require("path"));
10
+ function _interopRequireDefault(e) {
11
+ return e && e.__esModule ? e : { default: e };
12
+ }
6
13
  async function getAssets(dependencies, options) {
7
14
  const promises = [];
8
15
  const { processModuleFilter } = options;
9
16
  for (const module of dependencies.values()) {
10
17
  if (
11
- isJsModule(module) &&
18
+ (0, _js.isJsModule)(module) &&
12
19
  processModuleFilter(module) &&
13
- getJsOutput(module).type === "js/module/asset" &&
14
- path.relative(options.projectRoot, module.path) !== "package.json"
20
+ (0, _js.getJsOutput)(module).type === "js/module/asset" &&
21
+ _path.default.relative(options.projectRoot, module.path) !==
22
+ "package.json"
15
23
  ) {
16
24
  promises.push(
17
- getAssetData(
25
+ (0, _Assets.getAssetData)(
18
26
  module.path,
19
- path.relative(options.projectRoot, module.path),
27
+ _path.default.relative(options.projectRoot, module.path),
20
28
  options.assetPlugins,
21
29
  options.platform,
22
- options.publicPath
23
- )
30
+ options.publicPath,
31
+ ),
24
32
  );
25
33
  }
26
34
  }
27
35
  return await Promise.all(promises);
28
36
  }
29
- module.exports = getAssets;
@@ -9,14 +9,12 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- 'use strict';
13
-
14
12
  import type {AssetData} from '../../Assets';
15
- import type {Module, ReadOnlyDependencies} from '../types.flow';
13
+ import type {Module, ReadOnlyDependencies} from '../types';
16
14
 
17
- const {getAssetData} = require('../../Assets');
18
- const {getJsOutput, isJsModule} = require('./helpers/js');
19
- const path = require('path');
15
+ import {getAssetData} from '../../Assets';
16
+ import {getJsOutput, isJsModule} from './helpers/js';
17
+ import path from 'path';
20
18
 
21
19
  type Options = {
22
20
  +processModuleFilter: (module: Module<>) => boolean,
@@ -26,7 +24,7 @@ type Options = {
26
24
  publicPath: string,
27
25
  };
28
26
 
29
- async function getAssets(
27
+ export default async function getAssets(
30
28
  dependencies: ReadOnlyDependencies<>,
31
29
  options: Options,
32
30
  ): Promise<$ReadOnlyArray<AssetData>> {
@@ -54,5 +52,3 @@ async function getAssets(
54
52
 
55
53
  return await Promise.all(promises);
56
54
  }
57
-
58
- module.exports = getAssets;
@@ -0,0 +1,26 @@
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
+ * @oncall react_native
9
+ */
10
+
11
+ import type {Module} from '../types';
12
+ import type {
13
+ FBSourceFunctionMap,
14
+ MetroSourceMapSegmentTuple,
15
+ } from 'metro-source-map';
16
+
17
+ export type ExplodedSourceMap = ReadonlyArray<{
18
+ readonly map: Array<MetroSourceMapSegmentTuple>;
19
+ readonly firstLine1Based: number;
20
+ readonly functionMap: null | undefined | FBSourceFunctionMap;
21
+ readonly path: string;
22
+ }>;
23
+ export declare function getExplodedSourceMap(
24
+ modules: ReadonlyArray<Module>,
25
+ options: {readonly processModuleFilter: (module: Module) => boolean},
26
+ ): ExplodedSourceMap;
@@ -1,15 +1,19 @@
1
1
  "use strict";
2
2
 
3
- const { getJsOutput, isJsModule } = require("./helpers/js");
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.getExplodedSourceMap = getExplodedSourceMap;
7
+ var _js = require("./helpers/js");
4
8
  function getExplodedSourceMap(modules, options) {
5
9
  const modulesToProcess = modules
6
- .filter(isJsModule)
10
+ .filter(_js.isJsModule)
7
11
  .filter(options.processModuleFilter);
8
12
  const result = [];
9
13
  let firstLine1Based = 1;
10
14
  for (const module of modulesToProcess) {
11
15
  const { path } = module;
12
- const { lineCount, functionMap, map } = getJsOutput(module).data;
16
+ const { lineCount, functionMap, map } = (0, _js.getJsOutput)(module).data;
13
17
  result.push({
14
18
  firstLine1Based,
15
19
  functionMap,
@@ -20,6 +24,3 @@ function getExplodedSourceMap(modules, options) {
20
24
  }
21
25
  return result;
22
26
  }
23
- module.exports = {
24
- getExplodedSourceMap,
25
- };
@@ -9,15 +9,13 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- 'use strict';
13
-
14
- import type {Module} from '../types.flow';
12
+ import type {Module} from '../types';
15
13
  import type {
16
14
  FBSourceFunctionMap,
17
15
  MetroSourceMapSegmentTuple,
18
16
  } from 'metro-source-map';
19
17
 
20
- const {getJsOutput, isJsModule} = require('./helpers/js');
18
+ import {getJsOutput, isJsModule} from './helpers/js';
21
19
 
22
20
  export type ExplodedSourceMap = $ReadOnlyArray<{
23
21
  +map: Array<MetroSourceMapSegmentTuple>,
@@ -26,7 +24,7 @@ export type ExplodedSourceMap = $ReadOnlyArray<{
26
24
  +path: string,
27
25
  }>;
28
26
 
29
- function getExplodedSourceMap(
27
+ export function getExplodedSourceMap(
30
28
  modules: $ReadOnlyArray<Module<>>,
31
29
  options: {
32
30
  +processModuleFilter: (module: Module<>) => boolean,
@@ -47,7 +45,3 @@ function getExplodedSourceMap(
47
45
  }
48
46
  return result;
49
47
  }
50
-
51
- module.exports = {
52
- getExplodedSourceMap,
53
- };