metro 0.66.2 → 0.69.0

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 (255) hide show
  1. package/package.json +22 -24
  2. package/src/Assets.js +9 -9
  3. package/src/Assets.js.flow +5 -7
  4. package/src/Bundler/util.js +16 -15
  5. package/src/Bundler/util.js.flow +11 -10
  6. package/src/Bundler.js +21 -8
  7. package/src/Bundler.js.flow +19 -7
  8. package/src/DeltaBundler/DeltaCalculator.js +15 -15
  9. package/src/DeltaBundler/DeltaCalculator.js.flow +7 -7
  10. package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +13 -13
  11. package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +6 -7
  12. package/src/DeltaBundler/Serializers/baseJSBundle.js +4 -4
  13. package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +4 -4
  14. package/src/DeltaBundler/Serializers/getAllFiles.js +1 -1
  15. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +3 -3
  16. package/src/DeltaBundler/Serializers/getAssets.js +3 -3
  17. package/src/DeltaBundler/Serializers/getAssets.js.flow +4 -5
  18. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +4 -4
  19. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
  20. package/src/DeltaBundler/Serializers/getRamBundleInfo.js +20 -20
  21. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +9 -10
  22. package/src/DeltaBundler/Serializers/helpers/bytecode.js +11 -11
  23. package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +5 -6
  24. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +1 -1
  25. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -1
  26. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -2
  27. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
  28. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +1 -1
  29. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +1 -1
  30. package/src/DeltaBundler/Serializers/helpers/js.js +6 -6
  31. package/src/DeltaBundler/Serializers/helpers/js.js.flow +11 -12
  32. package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +4 -4
  33. package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +3 -3
  34. package/src/DeltaBundler/Serializers/helpers/processModules.js +4 -4
  35. package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
  36. package/src/DeltaBundler/Serializers/hmrJSBundle.js +9 -9
  37. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +9 -8
  38. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +6 -6
  39. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +3 -4
  40. package/src/DeltaBundler/Serializers/sourceMapObject.js +5 -5
  41. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
  42. package/src/DeltaBundler/Serializers/sourceMapString.js +2 -2
  43. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +3 -3
  44. package/src/DeltaBundler/Transformer.js +9 -9
  45. package/src/DeltaBundler/Transformer.js.flow +7 -9
  46. package/src/DeltaBundler/Worker.js +8 -11
  47. package/src/DeltaBundler/Worker.js.flow +8 -11
  48. package/src/DeltaBundler/WorkerFarm.js +14 -17
  49. package/src/DeltaBundler/WorkerFarm.js.flow +7 -10
  50. package/src/DeltaBundler/__fixtures__/hasteImpl.js +2 -2
  51. package/src/DeltaBundler/computeDelta.js +2 -2
  52. package/src/DeltaBundler/computeDelta.js.flow +2 -2
  53. package/src/DeltaBundler/getTransformCacheKey.js +4 -4
  54. package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -6
  55. package/src/DeltaBundler/mergeDeltas.js +2 -2
  56. package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
  57. package/src/DeltaBundler/traverseDependencies.js +22 -22
  58. package/src/DeltaBundler/traverseDependencies.js.flow +3 -3
  59. package/src/DeltaBundler/types.flow.js +1 -1
  60. package/src/DeltaBundler/types.flow.js.flow +1 -1
  61. package/src/DeltaBundler.js +5 -5
  62. package/src/DeltaBundler.js.flow +4 -4
  63. package/src/HmrServer.js +71 -55
  64. package/src/HmrServer.js.flow +40 -37
  65. package/src/IncrementalBundler/GraphNotFoundError.js +1 -1
  66. package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -1
  67. package/src/IncrementalBundler/ResourceNotFoundError.js +1 -1
  68. package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -1
  69. package/src/IncrementalBundler/RevisionNotFoundError.js +1 -1
  70. package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -1
  71. package/src/IncrementalBundler.js +44 -32
  72. package/src/IncrementalBundler.js.flow +30 -24
  73. package/src/ModuleGraph/module.js +3 -3
  74. package/src/ModuleGraph/module.js.flow +1 -1
  75. package/src/ModuleGraph/node-haste/HasteFS.js +2 -2
  76. package/src/ModuleGraph/node-haste/HasteFS.js.flow +1 -1
  77. package/src/ModuleGraph/node-haste/Module.js +1 -1
  78. package/src/ModuleGraph/node-haste/Module.js.flow +1 -1
  79. package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
  80. package/src/ModuleGraph/node-haste/ModuleCache.js.flow +3 -3
  81. package/src/ModuleGraph/node-haste/Package.js +3 -3
  82. package/src/ModuleGraph/node-haste/Package.js.flow +3 -3
  83. package/src/ModuleGraph/node-haste/node-haste.flow.js +1 -1
  84. package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -1
  85. package/src/ModuleGraph/node-haste/node-haste.js +42 -32
  86. package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -23
  87. package/src/ModuleGraph/output/indexed-ram-bundle.js +17 -17
  88. package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +41 -9
  89. package/src/ModuleGraph/output/multiple-files-ram-bundle.js +18 -18
  90. package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +21 -9
  91. package/src/ModuleGraph/output/plain-bundle.js +6 -6
  92. package/src/ModuleGraph/output/plain-bundle.js.flow +7 -7
  93. package/src/ModuleGraph/output/reverse-dependency-map-references.js +3 -3
  94. package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +4 -8
  95. package/src/ModuleGraph/output/util.js +31 -30
  96. package/src/ModuleGraph/output/util.js.flow +15 -16
  97. package/src/ModuleGraph/silent-console.js +2 -2
  98. package/src/ModuleGraph/silent-console.js.flow +1 -1
  99. package/src/ModuleGraph/test-helpers.js +7 -7
  100. package/src/ModuleGraph/types.flow.js +1 -1
  101. package/src/ModuleGraph/types.flow.js.flow +7 -7
  102. package/src/ModuleGraph/worker/JsFileWrapping.js +7 -7
  103. package/src/ModuleGraph/worker/JsFileWrapping.js.flow +3 -2
  104. package/src/ModuleGraph/worker/Platforms.js +2 -2
  105. package/src/ModuleGraph/worker/Platforms.js.flow +1 -1
  106. package/src/ModuleGraph/worker/collectDependencies.js +24 -25
  107. package/src/ModuleGraph/worker/collectDependencies.js.flow +15 -17
  108. package/src/ModuleGraph/worker/generate.js +2 -2
  109. package/src/ModuleGraph/worker/generate.js.flow +3 -3
  110. package/src/ModuleGraph/worker/generateImportNames.js +5 -5
  111. package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -5
  112. package/src/ModuleGraph/worker/mergeSourceMaps.js +8 -7
  113. package/src/ModuleGraph/worker/mergeSourceMaps.js.flow +3 -3
  114. package/src/Server/MultipartResponse.js +4 -8
  115. package/src/Server/symbolicate.js +8 -8
  116. package/src/Server/symbolicate.js.flow +17 -5
  117. package/src/Server.js +202 -150
  118. package/src/Server.js.flow +129 -87
  119. package/src/cli-utils.js +4 -4
  120. package/src/cli-utils.js.flow +15 -13
  121. package/src/cli.js +4 -4
  122. package/src/cli.js.flow +2 -4
  123. package/src/commands/build.js +23 -24
  124. package/src/commands/build.js.flow +6 -9
  125. package/src/commands/dependencies.js +25 -19
  126. package/src/commands/serve.js +17 -18
  127. package/src/commands/serve.js.flow +6 -9
  128. package/src/index.js +116 -51
  129. package/src/index.js.flow +107 -41
  130. package/src/integration_tests/basic_bundle/AssetRegistry.js +2 -2
  131. package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
  132. package/src/integration_tests/basic_bundle/Bar.js +2 -2
  133. package/src/integration_tests/basic_bundle/Bar.js.flow +1 -1
  134. package/src/integration_tests/basic_bundle/ErrorBundle.js +2 -2
  135. package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
  136. package/src/integration_tests/basic_bundle/Foo.js +2 -2
  137. package/src/integration_tests/basic_bundle/Foo.js.flow +1 -1
  138. package/src/integration_tests/basic_bundle/TestBundle.js +3 -2
  139. package/src/integration_tests/basic_bundle/TestBundle.js.flow +3 -1
  140. package/src/integration_tests/basic_bundle/TestPolyfill.js +1 -1
  141. package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +1 -1
  142. package/src/integration_tests/basic_bundle/TypeScript.ts +1 -1
  143. package/src/integration_tests/basic_bundle/import-export/export-1.js +2 -2
  144. package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +1 -1
  145. package/src/integration_tests/basic_bundle/import-export/export-2.js +2 -2
  146. package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +1 -1
  147. package/src/integration_tests/basic_bundle/import-export/export-3.js +2 -2
  148. package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +1 -1
  149. package/src/integration_tests/basic_bundle/import-export/export-4.js +2 -2
  150. package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +1 -1
  151. package/src/integration_tests/basic_bundle/import-export/export-5.js +2 -2
  152. package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +1 -1
  153. package/src/integration_tests/basic_bundle/import-export/export-6.js +2 -2
  154. package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +1 -1
  155. package/src/integration_tests/basic_bundle/import-export/export-null.js +2 -2
  156. package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +1 -1
  157. package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +2 -2
  158. package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +1 -1
  159. package/src/integration_tests/basic_bundle/import-export/index.js +8 -8
  160. package/src/integration_tests/basic_bundle/import-export/index.js.flow +1 -1
  161. package/src/integration_tests/basic_bundle/polyfill.js +1 -1
  162. package/src/integration_tests/execBundle.js +2 -2
  163. package/src/integration_tests/execBundle.js.flow +1 -1
  164. package/src/integration_tests/metro.config.js +8 -8
  165. package/src/lib/BatchProcessor.js +3 -3
  166. package/src/lib/BatchProcessor.js.flow +1 -1
  167. package/src/lib/JsonReporter.js +2 -2
  168. package/src/lib/JsonReporter.js.flow +1 -1
  169. package/src/lib/RamBundleParser.js +1 -1
  170. package/src/lib/RamBundleParser.js.flow +1 -1
  171. package/src/lib/TerminalReporter.js +14 -14
  172. package/src/lib/TerminalReporter.js.flow +9 -10
  173. package/src/lib/bundleToBytecode.js +6 -7
  174. package/src/lib/bundleToBytecode.js.flow +8 -7
  175. package/src/lib/bundleToString.js +3 -3
  176. package/src/lib/bundleToString.js.flow +5 -4
  177. package/src/lib/countLines.js +3 -7
  178. package/src/lib/countLines.js.flow +4 -7
  179. package/src/lib/createModuleIdFactory.js +2 -2
  180. package/src/lib/createModuleIdFactory.js.flow +1 -1
  181. package/src/lib/{attachWebsocketServer.js → createWebsocketServer.js} +18 -17
  182. package/src/lib/{attachWebsocketServer.js.flow → createWebsocketServer.js.flow} +12 -21
  183. package/src/lib/debounceAsyncQueue.js +2 -2
  184. package/src/lib/debounceAsyncQueue.js.flow +1 -1
  185. package/src/lib/formatBundlingError.js +21 -21
  186. package/src/lib/formatBundlingError.js.flow +6 -8
  187. package/src/lib/getAppendScripts.js +26 -27
  188. package/src/lib/getAppendScripts.js.flow +7 -8
  189. package/src/lib/getGraphId.js +3 -3
  190. package/src/lib/getGraphId.js.flow +3 -3
  191. package/src/lib/getMaxWorkers.js +2 -2
  192. package/src/lib/getMaxWorkers.js.flow +1 -1
  193. package/src/lib/getPreludeCode.js +2 -2
  194. package/src/lib/getPreludeCode.js.flow +1 -1
  195. package/src/lib/getPrependedScripts.js +15 -15
  196. package/src/lib/getPrependedScripts.js.flow +7 -8
  197. package/src/lib/logToConsole.js +1 -1
  198. package/src/lib/logToConsole.js.flow +3 -3
  199. package/src/lib/parseCustomTransformOptions.js +2 -2
  200. package/src/lib/parseCustomTransformOptions.js.flow +3 -3
  201. package/src/lib/parseOptionsFromUrl.js +7 -7
  202. package/src/lib/parseOptionsFromUrl.js.flow +29 -9
  203. package/src/lib/relativizeSourceMap.js +1 -1
  204. package/src/lib/relativizeSourceMap.js.flow +3 -3
  205. package/src/lib/reporting.js +5 -5
  206. package/src/lib/reporting.js.flow +16 -3
  207. package/src/lib/splitBundleOptions.js +5 -5
  208. package/src/lib/splitBundleOptions.js.flow +1 -1
  209. package/src/lib/transformHelpers.js +10 -10
  210. package/src/lib/transformHelpers.js.flow +5 -5
  211. package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
  212. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +46 -42
  213. package/src/node-haste/DependencyGraph/createHasteMap.js +99 -0
  214. package/src/node-haste/DependencyGraph/createHasteMap.js.flow +88 -0
  215. package/src/node-haste/DependencyGraph/{assets/empty-module.js → types.js} +2 -2
  216. package/src/node-haste/DependencyGraph/types.js.flow +88 -0
  217. package/src/node-haste/DependencyGraph.js +49 -117
  218. package/src/node-haste/DependencyGraph.js.flow +36 -111
  219. package/src/node-haste/Module.js +1 -1
  220. package/src/node-haste/Module.js.flow +3 -3
  221. package/src/node-haste/ModuleCache.js +54 -13
  222. package/src/node-haste/ModuleCache.js.flow +53 -12
  223. package/src/node-haste/Package.js +7 -9
  224. package/src/node-haste/Package.js.flow +1 -8
  225. package/src/node-haste/lib/AssetPaths.js +5 -5
  226. package/src/node-haste/lib/AssetPaths.js.flow +2 -4
  227. package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
  228. package/src/node-haste/lib/parsePlatformFilePath.js.flow +1 -1
  229. package/src/shared/output/RamBundle/as-assets.js +16 -17
  230. package/src/shared/output/RamBundle/as-assets.js.flow +11 -15
  231. package/src/shared/output/RamBundle/as-indexed-file.js +14 -15
  232. package/src/shared/output/RamBundle/as-indexed-file.js.flow +8 -12
  233. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +7 -7
  234. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -4
  235. package/src/shared/output/RamBundle/magic-number.js +1 -1
  236. package/src/shared/output/RamBundle/magic-number.js.flow +1 -1
  237. package/src/shared/output/RamBundle/util.js +21 -19
  238. package/src/shared/output/RamBundle/util.js.flow +5 -8
  239. package/src/shared/output/RamBundle/write-sourcemap.js +1 -1
  240. package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
  241. package/src/shared/output/RamBundle.js +2 -2
  242. package/src/shared/output/RamBundle.js.flow +4 -5
  243. package/src/shared/output/bundle.js +6 -6
  244. package/src/shared/output/bundle.js.flow +4 -5
  245. package/src/shared/output/meta.js +4 -5
  246. package/src/shared/output/meta.js.flow +2 -4
  247. package/src/shared/output/unbundle.js +1 -1
  248. package/src/shared/output/unbundle.js.flow +1 -1
  249. package/src/shared/output/writeFile.js +1 -1
  250. package/src/shared/output/writeFile.js.flow +1 -1
  251. package/src/shared/types.flow.js +1 -1
  252. package/src/shared/types.flow.js.flow +2 -2
  253. package/src/node-haste/DependencyGraph/assets/empty-module.js.flow +0 -9
  254. package/src/node-haste/types.js +0 -10
  255. package/src/node-haste/types.js.flow +0 -23
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,10 +11,10 @@
11
11
 
12
12
  const getAppendScripts = require("../../lib/getAppendScripts");
13
13
 
14
- const processBytecodeModules = require("./helpers/processBytecodeModules");
15
-
16
14
  const { getJsOutput } = require("./helpers/js");
17
15
 
16
+ const processBytecodeModules = require("./helpers/processBytecodeModules");
17
+
18
18
  const { compile } = require("metro-hermes-compiler");
19
19
 
20
20
  function baseBytecodeBundle(entryPoint, preModules, graph, options) {
@@ -26,7 +26,7 @@ function baseBytecodeBundle(entryPoint, preModules, graph, options) {
26
26
  filter: options.processModuleFilter,
27
27
  createModuleId: options.createModuleId,
28
28
  dev: options.dev,
29
- projectRoot: options.projectRoot
29
+ projectRoot: options.projectRoot,
30
30
  }; // Do not prepend polyfills or the require runtime when only modules are requested
31
31
 
32
32
  if (options.modulesOnly) {
@@ -50,9 +50,9 @@ function baseBytecodeBundle(entryPoint, preModules, graph, options) {
50
50
  runBeforeMainModule: options.runBeforeMainModule,
51
51
  runModule: options.runModule,
52
52
  sourceMapUrl: options.sourceMapUrl,
53
- sourceUrl: options.sourceUrl
53
+ sourceUrl: options.sourceUrl,
54
54
  }
55
- ).map(module => {
55
+ ).map((module) => {
56
56
  return {
57
57
  ...module,
58
58
  output: [
@@ -61,11 +61,11 @@ function baseBytecodeBundle(entryPoint, preModules, graph, options) {
61
61
  type: "bytecode/script/virtual",
62
62
  data: {
63
63
  bytecode: compile(getJsOutput(module).data.code, {
64
- sourceURL: module.path
65
- }).bytecode
66
- }
67
- }
68
- ]
64
+ sourceURL: module.path,
65
+ }).bytecode,
66
+ },
67
+ },
68
+ ],
69
69
  };
70
70
  }),
71
71
  processModulesOptions
@@ -75,14 +75,14 @@ function baseBytecodeBundle(entryPoint, preModules, graph, options) {
75
75
  processModulesOptions
76
76
  ).map(([module, bytecodeBundle]) => [
77
77
  options.createModuleId(module.path),
78
- bytecodeBundle
78
+ bytecodeBundle,
79
79
  ]);
80
80
  return {
81
81
  pre: processBytecodeModules(preModules, processModulesOptions).flatMap(
82
82
  ([_, bytecodeBundle]) => bytecodeBundle
83
83
  ),
84
84
  post,
85
- modules: processedModules
85
+ modules: processedModules,
86
86
  };
87
87
  }
88
88
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,12 +10,6 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const getAppendScripts = require('../../lib/getAppendScripts');
14
- const processBytecodeModules = require('./helpers/processBytecodeModules');
15
-
16
- const {getJsOutput} = require('./helpers/js');
17
- const {compile} = require('metro-hermes-compiler');
18
-
19
13
  import type {
20
14
  Graph,
21
15
  MixedOutput,
@@ -24,6 +18,11 @@ import type {
24
18
  } from '../types.flow';
25
19
  import type {BytecodeBundle} from 'metro-runtime/src/modules/types.flow';
26
20
 
21
+ const getAppendScripts = require('../../lib/getAppendScripts');
22
+ const {getJsOutput} = require('./helpers/js');
23
+ const processBytecodeModules = require('./helpers/processBytecodeModules');
24
+ const {compile} = require('metro-hermes-compiler');
25
+
27
26
  function baseBytecodeBundle(
28
27
  entryPoint: string,
29
28
  preModules: $ReadOnlyArray<Module<>>,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -22,7 +22,7 @@ function baseJSBundle(entryPoint, preModules, graph, options) {
22
22
  filter: options.processModuleFilter,
23
23
  createModuleId: options.createModuleId,
24
24
  dev: options.dev,
25
- projectRoot: options.projectRoot
25
+ projectRoot: options.projectRoot,
26
26
  }; // Do not prepend polyfills or the require runtime when only modules are requested
27
27
 
28
28
  if (options.modulesOnly) {
@@ -49,7 +49,7 @@ function baseJSBundle(entryPoint, preModules, graph, options) {
49
49
  runBeforeMainModule: options.runBeforeMainModule,
50
50
  runModule: options.runModule,
51
51
  sourceMapUrl: options.sourceMapUrl,
52
- sourceUrl: options.sourceUrl
52
+ sourceUrl: options.sourceUrl,
53
53
  }
54
54
  ),
55
55
  processModulesOptions
@@ -62,7 +62,7 @@ function baseJSBundle(entryPoint, preModules, graph, options) {
62
62
  modules: processModules(
63
63
  [...graph.dependencies.values()],
64
64
  processModulesOptions
65
- ).map(([module, code]) => [options.createModuleId(module.path), code])
65
+ ).map(([module, code]) => [options.createModuleId(module.path), code]),
66
66
  };
67
67
  }
68
68
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,9 +10,6 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const getAppendScripts = require('../../lib/getAppendScripts');
14
- const processModules = require('./helpers/processModules');
15
-
16
13
  import type {
17
14
  Graph,
18
15
  MixedOutput,
@@ -21,6 +18,9 @@ import type {
21
18
  } from '../types.flow';
22
19
  import type {Bundle} from 'metro-runtime/src/modules/types.flow';
23
20
 
21
+ const getAppendScripts = require('../../lib/getAppendScripts');
22
+ const processModules = require('./helpers/processModules');
23
+
24
24
  function baseJSBundle(
25
25
  entryPoint: string,
26
26
  preModules: $ReadOnlyArray<Module<>>,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,11 +10,11 @@
10
10
 
11
11
  'use strict';
12
12
 
13
+ import type {Graph, Module} from '../types.flow';
14
+
13
15
  const {getAssetFiles} = require('../../Assets');
14
16
  const {getJsOutput, isJsModule} = require('./helpers/js');
15
17
 
16
- import type {Graph, Module} from '../types.flow';
17
-
18
18
  type Options = {|
19
19
  platform: ?string,
20
20
  +processModuleFilter: (module: Module<>) => boolean,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -9,12 +9,12 @@
9
9
  */
10
10
  "use strict";
11
11
 
12
- const path = require("path");
13
-
14
12
  const { getAssetData } = require("../../Assets");
15
13
 
16
14
  const { getJsOutput, isJsModule } = require("./helpers/js");
17
15
 
16
+ const path = require("path");
17
+
18
18
  async function getAssets(dependencies, options) {
19
19
  const promises = [];
20
20
  const { processModuleFilter } = options;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,13 +10,12 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const path = require('path');
13
+ import type {AssetData} from '../../Assets';
14
+ import type {Dependencies, Module} from '../types.flow';
14
15
 
15
16
  const {getAssetData} = require('../../Assets');
16
17
  const {getJsOutput, isJsModule} = require('./helpers/js');
17
-
18
- import type {AssetData} from '../../Assets';
19
- import type {Dependencies, Module} from '../types.flow';
18
+ const path = require('path');
20
19
 
21
20
  type Options = {|
22
21
  +processModuleFilter: (module: Module<>) => boolean,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -9,7 +9,7 @@
9
9
  */
10
10
  "use strict";
11
11
 
12
- const { isJsModule, getJsOutput } = require("./helpers/js");
12
+ const { getJsOutput, isJsModule } = require("./helpers/js");
13
13
 
14
14
  function getExplodedSourceMap(modules, options) {
15
15
  const modulesToProcess = modules
@@ -25,7 +25,7 @@ function getExplodedSourceMap(modules, options) {
25
25
  firstLine1Based,
26
26
  functionMap,
27
27
  path,
28
- map
28
+ map,
29
29
  });
30
30
  firstLine1Based += lineCount;
31
31
  }
@@ -34,5 +34,5 @@ function getExplodedSourceMap(modules, options) {
34
34
  }
35
35
 
36
36
  module.exports = {
37
- getExplodedSourceMap
37
+ getExplodedSourceMap,
38
38
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,14 +10,14 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const {isJsModule, getJsOutput} = require('./helpers/js');
14
-
15
13
  import type {Module} from '../types.flow';
16
14
  import type {
17
- MetroSourceMapSegmentTuple,
18
15
  FBSourceFunctionMap,
16
+ MetroSourceMapSegmentTuple,
19
17
  } from 'metro-source-map';
20
18
 
19
+ const {getJsOutput, isJsModule} = require('./helpers/js');
20
+
21
21
  export type ExplodedSourceMap = $ReadOnlyArray<{|
22
22
  +map: Array<MetroSourceMapSegmentTuple>,
23
23
  +firstLine1Based: number,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -9,54 +9,54 @@
9
9
  */
10
10
  "use strict";
11
11
 
12
+ const { createRamBundleGroups } = require("../../Bundler/util");
13
+
12
14
  const getAppendScripts = require("../../lib/getAppendScripts");
13
15
 
14
16
  const getTransitiveDependencies = require("./helpers/getTransitiveDependencies");
15
17
 
16
- const nullthrows = require("nullthrows");
17
-
18
- const path = require("path");
19
-
20
- const { createRamBundleGroups } = require("../../Bundler/util");
21
-
22
18
  const { isJsModule, wrapModule } = require("./helpers/js");
23
19
 
24
20
  const { sourceMapObject } = require("./sourceMapObject");
25
21
 
22
+ const nullthrows = require("nullthrows");
23
+
24
+ const path = require("path");
25
+
26
26
  async function getRamBundleInfo(entryPoint, pre, graph, options) {
27
27
  let modules = [...pre, ...graph.dependencies.values()];
28
28
  modules = modules.concat(
29
29
  getAppendScripts(entryPoint, modules, graph.importBundleNames, options)
30
30
  );
31
- modules.forEach(module => options.createModuleId(module.path));
31
+ modules.forEach((module) => options.createModuleId(module.path));
32
32
  const ramModules = modules
33
33
  .filter(isJsModule)
34
34
  .filter(options.processModuleFilter)
35
- .map(module => ({
35
+ .map((module) => ({
36
36
  id: options.createModuleId(module.path),
37
37
  code: wrapModule(module, options),
38
38
  map: sourceMapObject([module], {
39
39
  excludeSource: options.excludeSource,
40
- processModuleFilter: options.processModuleFilter
40
+ processModuleFilter: options.processModuleFilter,
41
41
  }),
42
42
  name: path.basename(module.path),
43
43
  sourcePath: module.path,
44
44
  source: module.getSource().toString(),
45
45
  type: nullthrows(module.output.find(({ type }) => type.startsWith("js")))
46
- .type
46
+ .type,
47
47
  }));
48
48
  const { preloadedModules, ramGroups } = await _getRamOptions(
49
49
  entryPoint,
50
50
  {
51
51
  dev: options.dev,
52
- platform: options.platform
52
+ platform: options.platform,
53
53
  },
54
- filePath => getTransitiveDependencies(filePath, graph),
54
+ (filePath) => getTransitiveDependencies(filePath, graph),
55
55
  options.getTransformOptions
56
56
  );
57
57
  const startupModules = [];
58
58
  const lazyModules = [];
59
- ramModules.forEach(module => {
59
+ ramModules.forEach((module) => {
60
60
  if (preloadedModules.hasOwnProperty(module.sourcePath)) {
61
61
  startupModules.push(module);
62
62
  return;
@@ -90,10 +90,10 @@ async function getRamBundleInfo(entryPoint, pre, graph, options) {
90
90
  }
91
91
  );
92
92
  return {
93
- getDependencies: filePath => getTransitiveDependencies(filePath, graph),
93
+ getDependencies: (filePath) => getTransitiveDependencies(filePath, graph),
94
94
  groups,
95
95
  lazyModules,
96
- startupModules
96
+ startupModules,
97
97
  };
98
98
  }
99
99
  /**
@@ -109,7 +109,7 @@ async function _getRamOptions(
109
109
  if (getTransformOptions == null) {
110
110
  return {
111
111
  preloadedModules: {},
112
- ramGroups: []
112
+ ramGroups: [],
113
113
  };
114
114
  }
115
115
 
@@ -118,16 +118,16 @@ async function _getRamOptions(
118
118
  {
119
119
  dev: options.dev,
120
120
  hot: true,
121
- platform: options.platform
121
+ platform: options.platform,
122
122
  },
123
123
  /* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
124
124
  * error found when Flow v0.99 was deployed. To see the error, delete this
125
125
  * comment and run Flow. */
126
- async x => Array.from(getDependencies)
126
+ async (x) => Array.from(getDependencies)
127
127
  );
128
128
  return {
129
129
  preloadedModules: preloadedModules || {},
130
- ramGroups: ramGroups || []
130
+ ramGroups: ramGroups || [],
131
131
  };
132
132
  }
133
133
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,15 +10,6 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const getAppendScripts = require('../../lib/getAppendScripts');
14
- const getTransitiveDependencies = require('./helpers/getTransitiveDependencies');
15
- const nullthrows = require('nullthrows');
16
- const path = require('path');
17
-
18
- const {createRamBundleGroups} = require('../../Bundler/util');
19
- const {isJsModule, wrapModule} = require('./helpers/js');
20
- const {sourceMapObject} = require('./sourceMapObject');
21
-
22
13
  import type {
23
14
  ModuleTransportLike,
24
15
  RamModuleTransport,
@@ -26,6 +17,14 @@ import type {
26
17
  import type {Graph, Module, SerializerOptions} from '../types.flow';
27
18
  import type {GetTransformOptions} from 'metro-config/src/configTypes.flow.js';
28
19
 
20
+ const {createRamBundleGroups} = require('../../Bundler/util');
21
+ const getAppendScripts = require('../../lib/getAppendScripts');
22
+ const getTransitiveDependencies = require('./helpers/getTransitiveDependencies');
23
+ const {isJsModule, wrapModule} = require('./helpers/js');
24
+ const {sourceMapObject} = require('./sourceMapObject');
25
+ const nullthrows = require('nullthrows');
26
+ const path = require('path');
27
+
29
28
  type Options = {|
30
29
  ...SerializerOptions,
31
30
  +excludeSource: boolean,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,10 +11,10 @@
11
11
 
12
12
  const invariant = require("invariant");
13
13
 
14
- const path = require("path");
15
-
16
14
  const { compile } = require("metro-hermes-compiler");
17
15
 
16
+ const path = require("path");
17
+
18
18
  function wrapModule(module, options) {
19
19
  const output = getBytecodeOutput(module);
20
20
 
@@ -26,9 +26,9 @@ function wrapModule(module, options) {
26
26
  options.createModuleId(module.path),
27
27
  "[" +
28
28
  Array.from(module.dependencies.values())
29
- .map(dependency => options.createModuleId(dependency.absolutePath))
29
+ .map((dependency) => options.createModuleId(dependency.absolutePath))
30
30
  .join(",") +
31
- "]"
31
+ "]",
32
32
  ];
33
33
 
34
34
  if (options.dev) {
@@ -42,24 +42,24 @@ function wrapModule(module, options) {
42
42
  const headerCode = `globalThis.$$METRO_D=[${params.join(",")}];`;
43
43
  return [
44
44
  compile(headerCode, {
45
- sourceURL: module.path + "-virtual.js"
45
+ sourceURL: module.path + "-virtual.js",
46
46
  }).bytecode,
47
- output.data.bytecode
47
+ output.data.bytecode,
48
48
  ];
49
49
  }
50
50
 
51
51
  function getBytecodeOutput(module) {
52
52
  const output = module.output
53
53
  .filter(({ type }) => type.startsWith("bytecode/"))
54
- .map(output =>
54
+ .map((output) =>
55
55
  output.data.bytecode instanceof Buffer
56
56
  ? output // Re-create buffers after losing the Buffer instance when sending data over workers.
57
57
  : {
58
58
  ...output,
59
59
  data: {
60
60
  ...output.data,
61
- bytecode: Buffer.from(output.data.bytecode.data)
62
- }
61
+ bytecode: Buffer.from(output.data.bytecode.data),
62
+ },
63
63
  }
64
64
  );
65
65
  invariant(
@@ -78,5 +78,5 @@ function isBytecodeModule(module) {
78
78
  module.exports = {
79
79
  getBytecodeOutput,
80
80
  isBytecodeModule,
81
- wrapModule
81
+ wrapModule,
82
82
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,14 +10,13 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const invariant = require('invariant');
14
- const path = require('path');
15
-
16
- const {compile} = require('metro-hermes-compiler');
17
-
18
13
  import type {Module} from '../../types.flow';
19
14
  import type {BytecodeOutput} from 'metro-transform-worker';
20
15
 
16
+ const invariant = require('invariant');
17
+ const {compile} = require('metro-hermes-compiler');
18
+ const path = require('path');
19
+
21
20
  export type Options = {
22
21
  +createModuleId: string => number | string,
23
22
  +dev: boolean,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -15,7 +15,7 @@ function getSourceMapInfo(module, options) {
15
15
  return {
16
16
  ...getJsOutput(module).data,
17
17
  path: module.path,
18
- source: options.excludeSource ? "" : getModuleSource(module)
18
+ source: options.excludeSource ? "" : getModuleSource(module),
19
19
  };
20
20
  }
21
21
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -10,14 +10,14 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const {getJsOutput} = require('./js');
14
-
15
13
  import type {Module} from '../../types.flow';
16
14
  import type {
17
- MetroSourceMapSegmentTuple,
18
15
  FBSourceFunctionMap,
16
+ MetroSourceMapSegmentTuple,
19
17
  } from 'metro-source-map';
20
18
 
19
+ const {getJsOutput} = require('./js');
20
+
21
21
  function getSourceMapInfo(
22
22
  module: Module<>,
23
23
  options: {|
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -11,10 +11,10 @@
11
11
 
12
12
  const invariant = require("invariant");
13
13
 
14
- const path = require("path");
15
-
16
14
  const { addParamsToDefineCall } = require("metro-transform-plugins");
17
15
 
16
+ const path = require("path");
17
+
18
18
  function wrapModule(module, options) {
19
19
  const output = getJsOutput(module);
20
20
 
@@ -25,9 +25,9 @@ function wrapModule(module, options) {
25
25
  const moduleId = options.createModuleId(module.path);
26
26
  const params = [
27
27
  moduleId,
28
- Array.from(module.dependencies.values()).map(dependency =>
28
+ Array.from(module.dependencies.values()).map((dependency) =>
29
29
  options.createModuleId(dependency.absolutePath)
30
- )
30
+ ),
31
31
  ];
32
32
 
33
33
  if (options.dev) {
@@ -74,5 +74,5 @@ function isJsOutput(output) {
74
74
  module.exports = {
75
75
  getJsOutput,
76
76
  isJsModule,
77
- wrapModule
77
+ wrapModule,
78
78
  };