metro 0.84.4 → 0.86.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 (55) hide show
  1. package/package.json +17 -17
  2. package/src/Assets.js +3 -1
  3. package/src/Assets.js.flow +31 -25
  4. package/src/Bundler.d.ts +1 -5
  5. package/src/DeltaBundler/DeltaCalculator.d.ts +1 -16
  6. package/src/DeltaBundler/DeltaCalculator.js.flow +1 -1
  7. package/src/DeltaBundler/Graph.d.ts +1 -102
  8. package/src/DeltaBundler/Graph.js.flow +7 -7
  9. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +1 -1
  10. package/src/DeltaBundler/Serializers/getAssets.js.flow +1 -1
  11. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +3 -2
  12. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +6 -5
  13. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +3 -2
  14. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +10 -9
  15. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +3 -3
  16. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +4 -4
  17. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +2 -2
  18. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +7 -5
  19. package/src/DeltaBundler/Transformer.d.ts +2 -10
  20. package/src/DeltaBundler/Worker.flow.js.flow +1 -1
  21. package/src/DeltaBundler/WorkerFarm.d.ts +2 -47
  22. package/src/DeltaBundler/getTransformCacheKey.js.flow +3 -3
  23. package/src/DeltaBundler/types.js.flow +10 -10
  24. package/src/DeltaBundler.d.ts +1 -5
  25. package/src/HmrServer.d.ts +2 -45
  26. package/src/HmrServer.js.flow +10 -10
  27. package/src/IncrementalBundler.d.ts +1 -9
  28. package/src/IncrementalBundler.js.flow +9 -6
  29. package/src/ModuleGraph/worker/collectDependencies.d.ts +1 -2
  30. package/src/Server/symbolicate.js +66 -33
  31. package/src/Server/symbolicate.js.flow +90 -51
  32. package/src/Server.d.ts +3 -179
  33. package/src/Server.js.flow +25 -23
  34. package/src/index.d.ts +1 -23
  35. package/src/index.flow.js +1 -15
  36. package/src/index.flow.js.flow +0 -20
  37. package/src/lib/BatchProcessor.d.ts +1 -21
  38. package/src/lib/CountingSet.js.flow +1 -1
  39. package/src/lib/JsonReporter.d.ts +1 -2
  40. package/src/lib/JsonReporter.js.flow +4 -2
  41. package/src/lib/RamBundleParser.d.ts +1 -6
  42. package/src/lib/TerminalReporter.d.ts +2 -78
  43. package/src/lib/TerminalReporter.js.flow +1 -1
  44. package/src/lib/bundleToString.js.flow +2 -2
  45. package/src/lib/createWebsocketServer.js.flow +4 -4
  46. package/src/lib/formatBundlingError.js.flow +1 -1
  47. package/src/lib/getPreludeCode.js.flow +5 -5
  48. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +1 -13
  49. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +1 -1
  50. package/src/node-haste/DependencyGraph/createFileMap.js +23 -31
  51. package/src/node-haste/DependencyGraph/createFileMap.js.flow +23 -38
  52. package/src/node-haste/DependencyGraph.d.ts +1 -30
  53. package/src/node-haste/DependencyGraph.js.flow +2 -2
  54. package/src/shared/output/RamBundle/util.js.flow +4 -2
  55. package/src/shared/types.js.flow +31 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro",
3
- "version": "0.84.4",
3
+ "version": "0.86.0",
4
4
  "description": "🚇 The JavaScript bundler for React Native.",
5
5
  "main": "src/index.js",
6
6
  "bin": "src/cli.js",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/facebook/metro.git",
14
+ "url": "git+https://github.com/react/metro.git",
15
15
  "directory": "packages/metro"
16
16
  },
17
17
  "scripts": {
@@ -33,24 +33,24 @@
33
33
  "error-stack-parser": "^2.0.6",
34
34
  "flow-enums-runtime": "^0.0.6",
35
35
  "graceful-fs": "^4.2.4",
36
- "hermes-parser": "0.35.0",
36
+ "hermes-parser": "0.36.1",
37
37
  "image-size": "^1.0.2",
38
38
  "invariant": "^2.2.4",
39
39
  "jest-worker": "^29.7.0",
40
40
  "jsc-safe-url": "^0.2.2",
41
41
  "lodash.throttle": "^4.1.1",
42
- "metro-babel-transformer": "0.84.4",
43
- "metro-cache": "0.84.4",
44
- "metro-cache-key": "0.84.4",
45
- "metro-config": "0.84.4",
46
- "metro-core": "0.84.4",
47
- "metro-file-map": "0.84.4",
48
- "metro-resolver": "0.84.4",
49
- "metro-runtime": "0.84.4",
50
- "metro-source-map": "0.84.4",
51
- "metro-symbolicate": "0.84.4",
52
- "metro-transform-plugins": "0.84.4",
53
- "metro-transform-worker": "0.84.4",
42
+ "metro-babel-transformer": "0.86.0",
43
+ "metro-cache": "0.86.0",
44
+ "metro-cache-key": "0.86.0",
45
+ "metro-config": "0.86.0",
46
+ "metro-core": "0.86.0",
47
+ "metro-file-map": "0.86.0",
48
+ "metro-resolver": "0.86.0",
49
+ "metro-runtime": "0.86.0",
50
+ "metro-source-map": "0.86.0",
51
+ "metro-symbolicate": "0.86.0",
52
+ "metro-transform-plugins": "0.86.0",
53
+ "metro-transform-worker": "0.86.0",
54
54
  "mime-types": "^3.0.1",
55
55
  "nullthrows": "^1.1.1",
56
56
  "serialize-error": "^2.1.0",
@@ -71,7 +71,7 @@
71
71
  "dedent": "^0.7.0",
72
72
  "jest-snapshot": "^29.7.0",
73
73
  "jest-snapshot-serializer-raw": "^1.2.0",
74
- "metro-babel-register": "0.84.4",
74
+ "metro-babel-register": "0.86.0",
75
75
  "metro-memory-fs": "*",
76
76
  "mock-req": "^0.2.0",
77
77
  "mock-res": "^0.6.0",
@@ -80,6 +80,6 @@
80
80
  },
81
81
  "license": "MIT",
82
82
  "engines": {
83
- "node": "^20.19.4 || ^22.13.0 || ^24.3.0 || >= 25.0.0"
83
+ "node": "^22.13.0 || ^24.3.0 || >= 26.0.0"
84
84
  }
85
85
  }
package/src/Assets.js CHANGED
@@ -195,7 +195,9 @@ async function applyAssetDataPlugins(assetDataPlugins, assetData) {
195
195
  return assetData;
196
196
  }
197
197
  const [currentAssetPlugin, ...remainingAssetPlugins] = assetDataPlugins;
198
- const assetPluginFunction = require(currentAssetPlugin);
198
+ const mod = require(currentAssetPlugin);
199
+ const assetPluginFunction =
200
+ mod.__esModule === true && "default" in mod ? mod.default : mod;
199
201
  const resultAssetData = await assetPluginFunction(assetData);
200
202
  return await applyAssetDataPlugins(remainingAssetPlugins, resultAssetData);
201
203
  }
@@ -20,34 +20,34 @@ import getImageSize from 'image-size';
20
20
  import path from 'path';
21
21
 
22
22
  export type AssetInfo = {
23
- +files: Array<string>,
24
- +hash: string,
25
- +name: string,
26
- +scales: Array<number>,
27
- +type: string,
23
+ readonly files: Array<string>,
24
+ readonly hash: string,
25
+ readonly name: string,
26
+ readonly scales: Array<number>,
27
+ readonly type: string,
28
28
  };
29
29
 
30
30
  export type AssetDataWithoutFiles = {
31
- +__packager_asset: boolean,
32
- +fileSystemLocation: string,
33
- +hash: string,
34
- +height: ?number,
35
- +httpServerLocation: string,
36
- +name: string,
37
- +scales: Array<number>,
38
- +type: string,
39
- +width: ?number,
31
+ readonly __packager_asset: boolean,
32
+ readonly fileSystemLocation: string,
33
+ readonly hash: string,
34
+ readonly height: ?number,
35
+ readonly httpServerLocation: string,
36
+ readonly name: string,
37
+ readonly scales: Array<number>,
38
+ readonly type: string,
39
+ readonly width: ?number,
40
40
  ...
41
41
  };
42
42
  export type AssetDataFiltered = {
43
- +__packager_asset: boolean,
44
- +hash: string,
45
- +height: ?number,
46
- +httpServerLocation: string,
47
- +name: string,
48
- +scales: Array<number>,
49
- +type: string,
50
- +width: ?number,
43
+ readonly __packager_asset: boolean,
44
+ readonly hash: string,
45
+ readonly height: ?number,
46
+ readonly httpServerLocation: string,
47
+ readonly name: string,
48
+ readonly scales: Array<number>,
49
+ readonly type: string,
50
+ readonly width: ?number,
51
51
  ...
52
52
  };
53
53
 
@@ -74,7 +74,7 @@ export function getAssetSize(
74
74
  type: string,
75
75
  content: Buffer,
76
76
  filePath: string,
77
- ): ?{+width: number, +height: number} {
77
+ ): ?{readonly width: number, readonly height: number} {
78
78
  if (!isAssetTypeAnImage(type)) {
79
79
  return null;
80
80
  }
@@ -85,7 +85,10 @@ export function getAssetSize(
85
85
  return {width, height};
86
86
  }
87
87
 
88
- export type AssetData = AssetDataWithoutFiles & {+files: Array<string>, ...};
88
+ export type AssetData = AssetDataWithoutFiles & {
89
+ readonly files: Array<string>,
90
+ ...
91
+ };
89
92
 
90
93
  export type AssetDataPlugin = (
91
94
  assetData: AssetData,
@@ -249,7 +252,10 @@ async function applyAssetDataPlugins(
249
252
 
250
253
  const [currentAssetPlugin, ...remainingAssetPlugins] = assetDataPlugins;
251
254
  // $FlowFixMe[unsupported-syntax]: impossible to type a dynamic require.
252
- const assetPluginFunction: AssetDataPlugin = require(currentAssetPlugin);
255
+ const mod = require(currentAssetPlugin);
256
+ const assetPluginFunction: AssetDataPlugin =
257
+ mod.__esModule === true && 'default' in mod ? mod.default : mod;
258
+
253
259
  const resultAssetData = await assetPluginFunction(assetData);
254
260
  return await applyAssetDataPlugins(remainingAssetPlugins, resultAssetData);
255
261
  }
package/src/Bundler.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<3d5664309abdece0f247fcd0c53c3aaf>>
9
+ * @generated SignedSource<<fe2c52b16f1a3036429ec004623d3603>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/Bundler.js
@@ -20,7 +20,6 @@ import type {TransformOptions} from './DeltaBundler/Worker';
20
20
  import type EventEmitter from 'events';
21
21
  import type {ConfigT} from 'metro-config';
22
22
 
23
- import Transformer from './DeltaBundler/Transformer';
24
23
  import DependencyGraph from './node-haste/DependencyGraph';
25
24
 
26
25
  export type BundlerOptions = Readonly<{
@@ -28,9 +27,6 @@ export type BundlerOptions = Readonly<{
28
27
  watch?: boolean;
29
28
  }>;
30
29
  declare class Bundler {
31
- _depGraph: DependencyGraph;
32
- _initializedPromise: Promise<void>;
33
- _transformer: Transformer;
34
30
  constructor(config: ConfigT, options?: BundlerOptions);
35
31
  getWatcher(): EventEmitter;
36
32
  end(): Promise<void>;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<d06b53dd09157df95aeb941035d4ebf0>>
9
+ * @generated SignedSource<<1fbdc1ddc3526c8742b8c22d02311d38>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/DeltaCalculator.js
@@ -16,7 +16,6 @@
16
16
  */
17
17
 
18
18
  import type {DeltaResult, Options} from './types';
19
- import type {ChangeEvent} from 'metro-file-map';
20
19
 
21
20
  import {Graph} from './Graph';
22
21
  import EventEmitter from 'events';
@@ -27,14 +26,6 @@ import EventEmitter from 'events';
27
26
  * traverse the whole dependency tree for trivial small changes.
28
27
  */
29
28
  declare class DeltaCalculator<T> extends EventEmitter {
30
- _changeEventSource: EventEmitter;
31
- _options: Options<T>;
32
- _currentBuildPromise: null | undefined | Promise<DeltaResult<T>>;
33
- _deletedFiles: Set<string>;
34
- _modifiedFiles: Set<string>;
35
- _addedFiles: Set<string>;
36
- _requiresReset: boolean;
37
- _graph: Graph<T>;
38
29
  constructor(
39
30
  entryPoints: ReadonlySet<string>,
40
31
  changeEventSource: EventEmitter,
@@ -58,11 +49,5 @@ declare class DeltaCalculator<T> extends EventEmitter {
58
49
  * plus some metadata.
59
50
  */
60
51
  getGraph(): Graph<T>;
61
- _handleMultipleFileChanges: (changeEvent: ChangeEvent) => void;
62
- _getChangedDependencies(
63
- modifiedFiles: Set<string>,
64
- deletedFiles: Set<string>,
65
- addedFiles: Set<string>,
66
- ): Promise<DeltaResult<T>>;
67
52
  }
68
53
  export default DeltaCalculator;
@@ -182,7 +182,7 @@ export default class DeltaCalculator<T> extends EventEmitter {
182
182
 
183
183
  #shouldReset(
184
184
  canonicalPath: string,
185
- metadata: {+isSymlink: boolean, ...},
185
+ metadata: {readonly isSymlink: boolean, ...},
186
186
  ): boolean {
187
187
  if (metadata.isSymlink) {
188
188
  return true;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<2af7aa3b61c2afa4d8794e127666c226>>
9
+ * @generated SignedSource<<fc329765599e313b7d0cb6b45b7bbbdc>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/Graph.js
@@ -15,36 +15,12 @@
15
15
  * yarn run build-ts-defs (OSS)
16
16
  */
17
17
 
18
- /**
19
- * Portions of this code are based on the Synchronous Cycle Collection
20
- * algorithm described in:
21
- *
22
- * David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in
23
- * Reference Counted Systems. In Proceedings of the 15th European Conference on
24
- * Object-Oriented Programming (ECOOP '01). Springer-Verlag, Berlin,
25
- * Heidelberg, 207–235.
26
- *
27
- * Notable differences from the algorithm in the paper:
28
- * 1. Our implementation uses the inverseDependencies set (which we already
29
- * have to maintain) instead of a separate refcount variable. A module's
30
- * reference count is equal to the size of its inverseDependencies set, plus
31
- * 1 if it's an entry point of the graph.
32
- * 2. We keep the "root buffer" (possibleCycleRoots) free of duplicates by
33
- * making it a Set, instead of storing a "buffered" flag on each node.
34
- * 3. On top of tracking edges between nodes, we also count references between
35
- * nodes and entries in the importBundleNodes set.
36
- */
37
-
38
- import type {RequireContext} from '../lib/contextModule';
39
18
  import type {
40
19
  Dependencies,
41
- Dependency,
42
20
  GraphInputOptions,
43
21
  MixedOutput,
44
22
  Module,
45
- ModuleData,
46
23
  Options,
47
- ResolvedDependency,
48
24
  TransformInputOptions,
49
25
  } from './types';
50
26
 
@@ -55,22 +31,6 @@ export type Result<T> = {
55
31
  modified: Map<string, Module<T>>;
56
32
  deleted: Set<string>;
57
33
  };
58
- type Delta<T> = Readonly<{
59
- added: Set<string>;
60
- touched: Set<string>;
61
- deleted: Set<string>;
62
- updatedModuleData: ReadonlyMap<string, ModuleData<T>>;
63
- baseModuleData: Map<string, ModuleData<T>>;
64
- errors: ReadonlyMap<string, Error>;
65
- }>;
66
- type InternalOptions<T> = Readonly<{
67
- lazy: boolean;
68
- onDependencyAdd: () => unknown;
69
- onDependencyAdded: () => unknown;
70
- resolve: Options<T>['resolve'];
71
- transform: Options<T>['transform'];
72
- shallow: boolean;
73
- }>;
74
34
  export declare class Graph<T = MixedOutput> {
75
35
  readonly entryPoints: ReadonlySet<string>;
76
36
  readonly transformOptions: TransformInputOptions;
@@ -92,32 +52,6 @@ export declare class Graph<T = MixedOutput> {
92
52
  options: Options<T>,
93
53
  ): Promise<Result<T>>;
94
54
  initialTraverseDependencies(options: Options<T>): Promise<Result<T>>;
95
- _buildDelta(
96
- pathsToVisit: ReadonlySet<string>,
97
- options: InternalOptions<T>,
98
- moduleFilter?: (path: string) => boolean,
99
- ): Promise<Delta<T>>;
100
- _recursivelyCommitModule(
101
- path: string,
102
- delta: Delta<T>,
103
- options: InternalOptions<T>,
104
- commitOptions?: Readonly<{onlyRemove: boolean}>,
105
- ): Module<T>;
106
- _addDependency(
107
- parentModule: Module<T>,
108
- key: string,
109
- dependency: Dependency,
110
- requireContext: null | undefined | RequireContext,
111
- delta: Delta<T>,
112
- options: InternalOptions<T>,
113
- ): void;
114
- _removeDependency(
115
- parentModule: Module<T>,
116
- key: string,
117
- dependency: Dependency,
118
- delta: Delta<T>,
119
- options: InternalOptions<T>,
120
- ): void;
121
55
  /**
122
56
  * Collect a list of context modules which include a given file.
123
57
  */
@@ -136,39 +70,4 @@ export declare class Graph<T = MixedOutput> {
136
70
  * guarantee the same order between runs. This method mutates the passed graph.
137
71
  */
138
72
  reorderGraph(options: {shallow: boolean}): void;
139
- _reorderDependencies(
140
- module: Module<T>,
141
- orderedDependencies: Map<string, Module<T>>,
142
- options: {shallow: boolean},
143
- ): void;
144
- /** Garbage collection functions */
145
-
146
- _incrementImportBundleReference(
147
- dependency: ResolvedDependency,
148
- parentModule: Module<T>,
149
- ): void;
150
- _decrementImportBundleReference(
151
- dependency: ResolvedDependency,
152
- parentModule: Module<T>,
153
- ): void;
154
- _markModuleInUse(module: Module<T>): void;
155
- _children(
156
- module: Module<T>,
157
- options: InternalOptions<T>,
158
- ): Iterator<Module<T>>;
159
- _moduleSnapshot(module: Module<T>): ModuleData<T>;
160
- _releaseModule(
161
- module: Module<T>,
162
- delta: Delta<T>,
163
- options: InternalOptions<T>,
164
- ): void;
165
- _freeModule(module: Module<T>, delta: Delta<T>): void;
166
- _markAsPossibleCycleRoot(module: Module<T>): void;
167
- _collectCycles(delta: Delta<T>, options: InternalOptions<T>): void;
168
- _markGray(module: Module<T>, options: InternalOptions<T>): void;
169
- _scan(module: Module<T>, options: InternalOptions<T>): void;
170
- _scanBlack(module: Module<T>, options: InternalOptions<T>): void;
171
- _collectWhite(module: Module<T>, delta: Delta<T>): void;
172
-
173
- /** End of garbage collection functions */
174
73
  }
@@ -130,10 +130,10 @@ function isWeakOrLazy<T>(
130
130
  }
131
131
 
132
132
  export class Graph<T = MixedOutput> {
133
- +entryPoints: ReadonlySet<string>;
134
- +transformOptions: TransformInputOptions;
135
- +dependencies: Dependencies<T> = new Map();
136
- +#importBundleNodes: Map<
133
+ readonly entryPoints: ReadonlySet<string>;
134
+ readonly transformOptions: TransformInputOptions;
135
+ readonly dependencies: Dependencies<T> = new Map();
136
+ readonly #importBundleNodes: Map<
137
137
  string,
138
138
  Readonly<{
139
139
  inverseDependencies: CountingSet<string>,
@@ -141,9 +141,9 @@ export class Graph<T = MixedOutput> {
141
141
  > = new Map();
142
142
 
143
143
  /// GC state for nodes in the graph (this.dependencies)
144
- +#gc: {
145
- +color: Map<string, NodeColor>,
146
- +possibleCycleRoots: Set<string>,
144
+ readonly #gc: {
145
+ readonly color: Map<string, NodeColor>,
146
+ readonly possibleCycleRoots: Set<string>,
147
147
  } = {
148
148
  color: new Map(),
149
149
  possibleCycleRoots: new Set(),
@@ -16,7 +16,7 @@ import {getJsOutput, isJsModule} from './helpers/js';
16
16
 
17
17
  type Options = {
18
18
  platform: ?string,
19
- +processModuleFilter: (module: Module<>) => boolean,
19
+ readonly processModuleFilter: (module: Module<>) => boolean,
20
20
  };
21
21
 
22
22
  export default async function getAllFiles(
@@ -17,7 +17,7 @@ import {getJsOutput, isJsModule} from './helpers/js';
17
17
  import path from 'path';
18
18
 
19
19
  type Options = {
20
- +processModuleFilter: (module: Module<>) => boolean,
20
+ readonly processModuleFilter: (module: Module<>) => boolean,
21
21
  assetPlugins: ReadonlyArray<string>,
22
22
  platform: ?string,
23
23
  projectRoot: string,
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<623892927b76c4f68802bb69f19d9974>>
9
+ * @generated SignedSource<<2f0ab0435f64798986366df74674d02a>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/Serializers/getExplodedSourceMap.js
@@ -19,10 +19,11 @@ import type {Module} from '../types';
19
19
  import type {
20
20
  FBSourceFunctionMap,
21
21
  MetroSourceMapSegmentTuple,
22
+ VlqMap,
22
23
  } from 'metro-source-map';
23
24
 
24
25
  export type ExplodedSourceMap = ReadonlyArray<{
25
- readonly map: Array<MetroSourceMapSegmentTuple>;
26
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap;
26
27
  readonly firstLine1Based: number;
27
28
  readonly functionMap: null | undefined | FBSourceFunctionMap;
28
29
  readonly path: string;
@@ -13,21 +13,22 @@ import type {Module} from '../types';
13
13
  import type {
14
14
  FBSourceFunctionMap,
15
15
  MetroSourceMapSegmentTuple,
16
+ VlqMap,
16
17
  } from 'metro-source-map';
17
18
 
18
19
  import {getJsOutput, isJsModule} from './helpers/js';
19
20
 
20
21
  export type ExplodedSourceMap = ReadonlyArray<{
21
- +map: Array<MetroSourceMapSegmentTuple>,
22
- +firstLine1Based: number,
23
- +functionMap: ?FBSourceFunctionMap,
24
- +path: string,
22
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
23
+ readonly firstLine1Based: number,
24
+ readonly functionMap: ?FBSourceFunctionMap,
25
+ readonly path: string,
25
26
  }>;
26
27
 
27
28
  export function getExplodedSourceMap(
28
29
  modules: ReadonlyArray<Module<>>,
29
30
  options: {
30
- +processModuleFilter: (module: Module<>) => boolean,
31
+ readonly processModuleFilter: (module: Module<>) => boolean,
31
32
  },
32
33
  ): ExplodedSourceMap {
33
34
  const modulesToProcess = modules
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<cd7e523b4fdfbff33e663b21c4529401>>
9
+ * @generated SignedSource<<af4dc08fc7e742357f7e2c12d3c89662>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js
@@ -19,6 +19,7 @@ import type {Module} from '../../types';
19
19
  import type {
20
20
  FBSourceFunctionMap,
21
21
  MetroSourceMapSegmentTuple,
22
+ VlqMap,
22
23
  } from 'metro-source-map';
23
24
 
24
25
  declare function getSourceMapInfo(
@@ -29,7 +30,7 @@ declare function getSourceMapInfo(
29
30
  getSourceUrl: null | undefined | ((module: Module) => string);
30
31
  },
31
32
  ): {
32
- readonly map: Array<MetroSourceMapSegmentTuple>;
33
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap;
33
34
  readonly functionMap: null | undefined | FBSourceFunctionMap;
34
35
  readonly code: string;
35
36
  readonly path: string;
@@ -13,6 +13,7 @@ import type {Module} from '../../types';
13
13
  import type {
14
14
  FBSourceFunctionMap,
15
15
  MetroSourceMapSegmentTuple,
16
+ VlqMap,
16
17
  } from 'metro-source-map';
17
18
 
18
19
  import {getJsOutput} from './js';
@@ -20,18 +21,18 @@ import {getJsOutput} from './js';
20
21
  export default function getSourceMapInfo(
21
22
  module: Module<>,
22
23
  options: {
23
- +excludeSource: boolean,
24
- +shouldAddToIgnoreList: (Module<>) => boolean,
24
+ readonly excludeSource: boolean,
25
+ readonly shouldAddToIgnoreList: (Module<>) => boolean,
25
26
  getSourceUrl: ?(module: Module<>) => string,
26
27
  },
27
28
  ): {
28
- +map: Array<MetroSourceMapSegmentTuple>,
29
- +functionMap: ?FBSourceFunctionMap,
30
- +code: string,
31
- +path: string,
32
- +source: string,
33
- +lineCount: number,
34
- +isIgnored: boolean,
29
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
30
+ readonly functionMap: ?FBSourceFunctionMap,
31
+ readonly code: string,
32
+ readonly path: string,
33
+ readonly source: string,
34
+ readonly lineCount: number,
35
+ readonly isIgnored: boolean,
35
36
  } {
36
37
  return {
37
38
  ...getJsOutput(module).data,
@@ -148,9 +148,9 @@ export default function hmrJSBundle(
148
148
  graph: ReadOnlyGraph<>,
149
149
  options: Options,
150
150
  ): {
151
- +added: ReadonlyArray<HmrModule>,
152
- +deleted: ReadonlyArray<number>,
153
- +modified: ReadonlyArray<HmrModule>,
151
+ readonly added: ReadonlyArray<HmrModule>,
152
+ readonly deleted: ReadonlyArray<number>,
153
+ readonly modified: ReadonlyArray<HmrModule>,
154
154
  } {
155
155
  return {
156
156
  added: generateModules(delta.added.values(), graph, options),
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<49bc83c20821024a7b77f5d5c3168d62>>
9
+ * @generated SignedSource<<6c7d6cff28e917c03235af1d0c98db4e>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js
@@ -17,7 +17,7 @@
17
17
 
18
18
  import type {Module} from '../types';
19
19
 
20
- import {fromRawMappings, fromRawMappingsNonBlocking} from 'metro-source-map';
20
+ import {fromRawMappingsIndexed} from 'metro-source-map';
21
21
 
22
22
  export type SourceMapGeneratorOptions = Readonly<{
23
23
  excludeSource: boolean;
@@ -28,9 +28,9 @@ export type SourceMapGeneratorOptions = Readonly<{
28
28
  declare function sourceMapGenerator(
29
29
  modules: ReadonlyArray<Module>,
30
30
  options: SourceMapGeneratorOptions,
31
- ): ReturnType<typeof fromRawMappings>;
31
+ ): ReturnType<typeof fromRawMappingsIndexed>;
32
32
  declare function sourceMapGeneratorNonBlocking(
33
33
  modules: ReadonlyArray<Module>,
34
34
  options: SourceMapGeneratorOptions,
35
- ): ReturnType<typeof fromRawMappingsNonBlocking>;
35
+ ): Promise<ReturnType<typeof fromRawMappingsIndexed>>;
36
36
  export {sourceMapGenerator, sourceMapGeneratorNonBlocking};
@@ -66,11 +66,11 @@ function sourceMapGenerator(modules, options) {
66
66
  "Expected getSourceMapInfosImpl() to finish synchronously.",
67
67
  );
68
68
  }
69
- return (0, _metroSourceMap.fromRawMappings)(sourceMapInfos);
69
+ return (0, _metroSourceMap.fromRawMappingsIndexed)(sourceMapInfos);
70
70
  }
71
71
  async function sourceMapGeneratorNonBlocking(modules, options) {
72
72
  const sourceMapInfos = await new Promise((resolve) => {
73
73
  getSourceMapInfosImpl(false, resolve, modules, options);
74
74
  });
75
- return (0, _metroSourceMap.fromRawMappingsNonBlocking)(sourceMapInfos);
75
+ return (0, _metroSourceMap.fromRawMappingsIndexed)(sourceMapInfos);
76
76
  }
@@ -13,7 +13,7 @@ import type {Module} from '../types';
13
13
 
14
14
  import getSourceMapInfo from './helpers/getSourceMapInfo';
15
15
  import {isJsModule} from './helpers/js';
16
- import {fromRawMappings, fromRawMappingsNonBlocking} from 'metro-source-map';
16
+ import {fromRawMappingsIndexed} from 'metro-source-map';
17
17
 
18
18
  export type SourceMapGeneratorOptions = Readonly<{
19
19
  excludeSource: boolean,
@@ -78,7 +78,7 @@ function getSourceMapInfosImpl(
78
78
  function sourceMapGenerator(
79
79
  modules: ReadonlyArray<Module<>>,
80
80
  options: SourceMapGeneratorOptions,
81
- ): ReturnType<typeof fromRawMappings> {
81
+ ): ReturnType<typeof fromRawMappingsIndexed> {
82
82
  let sourceMapInfos;
83
83
  getSourceMapInfosImpl(
84
84
  true,
@@ -93,19 +93,21 @@ function sourceMapGenerator(
93
93
  'Expected getSourceMapInfosImpl() to finish synchronously.',
94
94
  );
95
95
  }
96
- return fromRawMappings(sourceMapInfos);
96
+ return fromRawMappingsIndexed(sourceMapInfos);
97
97
  }
98
98
 
99
99
  async function sourceMapGeneratorNonBlocking(
100
100
  modules: ReadonlyArray<Module<>>,
101
101
  options: SourceMapGeneratorOptions,
102
- ): ReturnType<typeof fromRawMappingsNonBlocking> {
102
+ ): Promise<ReturnType<typeof fromRawMappingsIndexed>> {
103
103
  const sourceMapInfos = await new Promise<
104
104
  ReadonlyArray<ReturnType<typeof getSourceMapInfo>>,
105
105
  >(resolve => {
106
106
  getSourceMapInfosImpl(false, resolve, modules, options);
107
107
  });
108
- return fromRawMappingsNonBlocking(sourceMapInfos);
108
+ // Building an index map is a cheap synchronous passthrough (VLQ maps carry
109
+ // over verbatim); only gathering the per-module info above needs to yield.
110
+ return fromRawMappingsIndexed(sourceMapInfos);
109
111
  }
110
112
 
111
113
  export {sourceMapGenerator, sourceMapGeneratorNonBlocking};