metro 0.70.3 → 0.71.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 (67) hide show
  1. package/package.json +20 -20
  2. package/src/Assets.js.flow +4 -4
  3. package/src/Bundler/util.js +1 -1
  4. package/src/Bundler/util.js.flow +2 -2
  5. package/src/Bundler.js +17 -10
  6. package/src/Bundler.js.flow +19 -14
  7. package/src/DeltaBundler/DeltaCalculator.js +13 -17
  8. package/src/DeltaBundler/DeltaCalculator.js.flow +15 -20
  9. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
  10. package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
  11. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
  12. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +6 -6
  13. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
  14. package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +2 -2
  15. package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +2 -2
  16. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +2 -2
  17. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
  18. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
  19. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
  20. package/src/DeltaBundler/Worker.js.flow +4 -4
  21. package/src/DeltaBundler/WorkerFarm.js.flow +4 -4
  22. package/src/DeltaBundler/getTransformCacheKey.js.flow +2 -2
  23. package/src/DeltaBundler/{traverseDependencies.js → graphOperations.js} +43 -32
  24. package/src/DeltaBundler/{traverseDependencies.js.flow → graphOperations.js.flow} +52 -37
  25. package/src/DeltaBundler/types.flow.js.flow +36 -30
  26. package/src/DeltaBundler.js +14 -6
  27. package/src/DeltaBundler.js.flow +14 -10
  28. package/src/HmrServer.js.flow +6 -6
  29. package/src/IncrementalBundler.js +1 -1
  30. package/src/IncrementalBundler.js.flow +8 -8
  31. package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
  32. package/src/ModuleGraph/node-haste/ModuleCache.js.flow +1 -1
  33. package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +2 -2
  34. package/src/ModuleGraph/node-haste/node-haste.js +4 -4
  35. package/src/ModuleGraph/node-haste/node-haste.js.flow +13 -7
  36. package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +2 -2
  37. package/src/ModuleGraph/output/plain-bundle.js.flow +2 -2
  38. package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +8 -8
  39. package/src/ModuleGraph/output/util.js.flow +2 -2
  40. package/src/ModuleGraph/types.flow.js.flow +37 -37
  41. package/src/ModuleGraph/worker/collectDependencies.js.flow +2 -2
  42. package/src/Server/symbolicate.js.flow +1 -1
  43. package/src/Server.js.flow +18 -18
  44. package/src/commands/build.js.flow +2 -2
  45. package/src/commands/serve.js.flow +2 -2
  46. package/src/index.js +32 -18
  47. package/src/index.js.flow +42 -32
  48. package/src/lib/bundleToBytecode.js.flow +2 -2
  49. package/src/lib/bundleToString.js.flow +2 -2
  50. package/src/lib/getPreludeCode.js.flow +2 -2
  51. package/src/lib/transformHelpers.js.flow +2 -2
  52. package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -1
  53. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +5 -12
  54. package/src/node-haste/DependencyGraph/createHasteMap.js +9 -7
  55. package/src/node-haste/DependencyGraph/createHasteMap.js.flow +6 -9
  56. package/src/node-haste/DependencyGraph.js +31 -27
  57. package/src/node-haste/DependencyGraph.js.flow +43 -37
  58. package/src/node-haste/ModuleCache.js.flow +1 -1
  59. package/src/node-haste/lib/AssetPaths.js.flow +2 -2
  60. package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
  61. package/src/shared/output/RamBundle/as-indexed-file.js.flow +1 -1
  62. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +2 -2
  63. package/src/shared/types.flow.js.flow +14 -14
  64. package/src/DeltaBundler/computeDelta.js +0 -42
  65. package/src/DeltaBundler/computeDelta.js.flow +0 -47
  66. package/src/node-haste/DependencyGraph/types.js +0 -10
  67. package/src/node-haste/DependencyGraph/types.js.flow +0 -88
@@ -43,7 +43,7 @@ class IncrementalBundler {
43
43
  constructor(config, options) {
44
44
  this._config = config;
45
45
  this._bundler = new Bundler(config, options);
46
- this._deltaBundler = new DeltaBundler(this._bundler);
46
+ this._deltaBundler = new DeltaBundler(this._bundler.getWatcher());
47
47
  }
48
48
 
49
49
  end() {
@@ -33,24 +33,24 @@ export opaque type RevisionId: string = string;
33
33
 
34
34
  export type OutputGraph = Graph<>;
35
35
 
36
- type OtherOptions = {|
36
+ type OtherOptions = {
37
37
  +onProgress: $PropertyType<DeltaBundlerOptions<>, 'onProgress'>,
38
38
  +shallow: boolean,
39
- |};
39
+ };
40
40
 
41
- export type GraphRevision = {|
41
+ export type GraphRevision = {
42
42
  // Identifies the last computed revision.
43
43
  +id: RevisionId,
44
44
  +date: Date,
45
45
  +graphId: GraphId,
46
46
  +graph: OutputGraph,
47
47
  +prepend: $ReadOnlyArray<Module<>>,
48
- |};
48
+ };
49
49
 
50
- export type IncrementalBundlerOptions = $ReadOnly<{|
50
+ export type IncrementalBundlerOptions = $ReadOnly<{
51
51
  hasReducedPerformance?: boolean,
52
52
  watch?: boolean,
53
- |}>;
53
+ }>;
54
54
 
55
55
  function createRevisionId(): RevisionId {
56
56
  return crypto.randomBytes(8).toString('hex');
@@ -73,7 +73,7 @@ class IncrementalBundler {
73
73
  constructor(config: ConfigT, options?: IncrementalBundlerOptions) {
74
74
  this._config = config;
75
75
  this._bundler = new Bundler(config, options);
76
- this._deltaBundler = new DeltaBundler(this._bundler);
76
+ this._deltaBundler = new DeltaBundler(this._bundler.getWatcher());
77
77
  }
78
78
 
79
79
  end(): void {
@@ -178,7 +178,7 @@ class IncrementalBundler {
178
178
  onProgress: null,
179
179
  shallow: false,
180
180
  },
181
- ): Promise<{|+graph: OutputGraph, +prepend: $ReadOnlyArray<Module<>>|}> {
181
+ ): Promise<{+graph: OutputGraph, +prepend: $ReadOnlyArray<Module<>>}> {
182
182
  const graph = await this.buildGraphForEntries(
183
183
  [entryFile],
184
184
  transformOptions,
@@ -24,7 +24,7 @@ module.exports = class ModuleCache {
24
24
  getModule(path) {
25
25
  // This is hacky as hell... `ModuleGraph` handles relative paths but which
26
26
  // start with a slash (so we can have `/js/foo.js` or even `/../foo.js`).
27
- // This does not play well with `jest-haste-map`, which tries to convert
27
+ // This does not play well with `metro-file-map`, which tries to convert
28
28
  // paths to absolute (https://fburl.com/vbwmjsxa) causing an additional
29
29
  // slashed to be prepended in the file path.
30
30
  // TODO: Refactor the way metro-buck handles paths to make them either
@@ -36,7 +36,7 @@ module.exports = class ModuleCache {
36
36
  getModule(path: string): Module {
37
37
  // This is hacky as hell... `ModuleGraph` handles relative paths but which
38
38
  // start with a slash (so we can have `/js/foo.js` or even `/../foo.js`).
39
- // This does not play well with `jest-haste-map`, which tries to convert
39
+ // This does not play well with `metro-file-map`, which tries to convert
40
40
  // paths to absolute (https://fburl.com/vbwmjsxa) causing an additional
41
41
  // slashed to be prepended in the file path.
42
42
  // TODO: Refactor the way metro-buck handles paths to make them either
@@ -55,13 +55,13 @@ export type FastFS = {
55
55
  ...
56
56
  };
57
57
 
58
- type HasteMapOptions = {|
58
+ type HasteMapOptions = {
59
59
  extensions: Extensions,
60
60
  files: Array<string>,
61
61
  moduleCache: ModuleCache,
62
62
  platforms: Platforms,
63
63
  preferNativePlatform: true,
64
- |};
64
+ };
65
65
 
66
66
  declare class HasteMap {
67
67
  // node-haste/DependencyGraph/HasteMap.js
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _jestHasteMap = require("jest-haste-map");
3
+ var _metroFileMap = require("metro-file-map");
4
4
 
5
5
  /**
6
6
  * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -45,7 +45,7 @@ const NULL_MODULE = {
45
45
  };
46
46
  const NODE_MODULES = path.sep + "node_modules" + path.sep;
47
47
 
48
- const isNodeModules = (file) => file.includes(NODE_MODULES); // This function maps the ModuleGraph data structure to jest-haste-map's ModuleMap
48
+ const isNodeModules = (file) => file.includes(NODE_MODULES); // This function maps the ModuleGraph data structure to metro-file-map's ModuleMap
49
49
 
50
50
  const createModuleMap = ({ files, moduleCache, sourceExts, platforms }) => {
51
51
  const platformSet = new Set(
@@ -78,7 +78,7 @@ const createModuleMap = ({ files, moduleCache, sourceExts, platforms }) => {
78
78
  const mapModule = map.get(id) || Object.create(null);
79
79
  const platform =
80
80
  parsePlatformFilePath(filePath, platformSet).platform || GENERIC_PLATFORM;
81
- const existingModule = mapModule[platform]; // 0 = Module, 1 = Package in jest-haste-map
81
+ const existingModule = mapModule[platform]; // 0 = Module, 1 = Package in metro-file-map
82
82
 
83
83
  mapModule[platform] = [filePath, module.type === "Package" ? 1 : 0];
84
84
 
@@ -141,7 +141,7 @@ exports.createResolveFn = function (options) {
141
141
  mainFields: options.mainFields,
142
142
  // $FlowFixMe -- error revealed by types-first codemod
143
143
  moduleCache,
144
- moduleMap: new _jestHasteMap.ModuleMap({
144
+ moduleMap: new _metroFileMap.ModuleMap({
145
145
  duplicates: new Map(),
146
146
  map: createModuleMap({
147
147
  files,
@@ -11,9 +11,10 @@
11
11
  import type {Moduleish} from '../../node-haste/DependencyGraph/ModuleResolution';
12
12
  import type {ResolveFn, TransformedCodeFile} from '../types.flow';
13
13
  import type {Extensions, Path} from './node-haste.flow';
14
+ import type {ModuleMapData, ModuleMapItem} from 'metro-file-map';
14
15
  import type {CustomResolver} from 'metro-resolver';
15
16
 
16
- import {ModuleMap} from 'jest-haste-map';
17
+ import {ModuleMap} from 'metro-file-map';
17
18
 
18
19
  const {
19
20
  ModuleResolver,
@@ -25,7 +26,7 @@ const ModuleCache = require('./ModuleCache');
25
26
  const defaults = require('metro-config/src/defaults/defaults');
26
27
  const path = require('path');
27
28
 
28
- type ResolveOptions = {|
29
+ type ResolveOptions = {
29
30
  assetExts: Extensions,
30
31
  assetResolutions: $ReadOnlyArray<string>,
31
32
  +disableHierarchicalLookup: boolean,
@@ -38,7 +39,7 @@ type ResolveOptions = {|
38
39
  resolveRequest?: ?CustomResolver,
39
40
  +sourceExts: Extensions,
40
41
  transformedFiles: {[path: Path]: TransformedCodeFile, ...},
41
- |};
42
+ };
42
43
 
43
44
  const NATIVE_PLATFORM = 'native';
44
45
  const GENERIC_PLATFORM = 'g';
@@ -57,8 +58,13 @@ const NULL_MODULE: Moduleish = {
57
58
  const NODE_MODULES = path.sep + 'node_modules' + path.sep;
58
59
  const isNodeModules = file => file.includes(NODE_MODULES);
59
60
 
60
- // This function maps the ModuleGraph data structure to jest-haste-map's ModuleMap
61
- const createModuleMap = ({files, moduleCache, sourceExts, platforms}) => {
61
+ // This function maps the ModuleGraph data structure to metro-file-map's ModuleMap
62
+ const createModuleMap = ({
63
+ files,
64
+ moduleCache,
65
+ sourceExts,
66
+ platforms,
67
+ }): ModuleMapData => {
62
68
  const platformSet = new Set(
63
69
  (platforms ?? defaults.platforms).concat([NATIVE_PLATFORM]),
64
70
  );
@@ -83,13 +89,13 @@ const createModuleMap = ({files, moduleCache, sourceExts, platforms}) => {
83
89
  return;
84
90
  }
85
91
 
86
- const mapModule = map.get(id) || Object.create(null);
92
+ const mapModule: ModuleMapItem = map.get(id) || Object.create(null);
87
93
 
88
94
  const platform =
89
95
  parsePlatformFilePath(filePath, platformSet).platform || GENERIC_PLATFORM;
90
96
 
91
97
  const existingModule = mapModule[platform];
92
- // 0 = Module, 1 = Package in jest-haste-map
98
+ // 0 = Module, 1 = Package in metro-file-map
93
99
  mapModule[platform] = [filePath, module.type === 'Package' ? 1 : 0];
94
100
 
95
101
  if (existingModule && existingModule[0] !== filePath) {
@@ -45,11 +45,11 @@ function asIndexedRamBundle({
45
45
  requireCalls: Iterable<Module>,
46
46
  segmentID: number,
47
47
  sourceMapPath?: ?string,
48
- }>): {|
48
+ }>): {
49
49
  code: string | Buffer,
50
50
  extraFiles?: Iterable<[string, string | Buffer]>,
51
51
  map: IndexMap,
52
- |} {
52
+ } {
53
53
  const idForPath = (x: {path: string, ...}) => idsForPath(x).moduleId;
54
54
  const [startup, deferred] = partition(modules, preloadedModules);
55
55
  const startupModules = [...startup, ...requireCalls];
@@ -27,11 +27,11 @@ function asPlainBundle({
27
27
  requireCalls,
28
28
  sourceMapPath,
29
29
  enableIDInlining,
30
- }: OutputFnArg): {|
30
+ }: OutputFnArg): {
31
31
  code: string | Buffer,
32
32
  extraFiles?: Iterable<[string, string | Buffer]>,
33
33
  map: MixedSourceMap,
34
- |} {
34
+ } {
35
35
  const builder = new BundleBuilder(filename);
36
36
  const modIdForPath = (x: {path: string, ...}) => idsForPath(x).moduleId;
37
37
 
@@ -17,18 +17,18 @@ import typeof * as Types from '@babel/types';
17
17
  import invariant from 'invariant';
18
18
  import nullthrows from 'nullthrows';
19
19
 
20
- type State = {|
21
- opts: {|
20
+ type State = {
21
+ opts: {
22
22
  +dependencyIds: $ReadOnlyArray<number>,
23
23
  +globalPrefix: string,
24
- |},
25
- |};
24
+ },
25
+ };
26
26
 
27
- function reverseDependencyMapReferences({types: t}: {types: Types, ...}): {|
28
- visitor: {|
27
+ function reverseDependencyMapReferences({types: t}: {types: Types, ...}): {
28
+ visitor: {
29
29
  CallExpression: (path: NodePath<CallExpression>, state: State) => void,
30
- |},
31
- |} {
30
+ },
31
+ } {
32
32
  return {
33
33
  visitor: {
34
34
  CallExpression(path: NodePath<CallExpression>, state: State) {
@@ -238,10 +238,10 @@ function getModuleCodeAndMap(
238
238
  dependencyMapReservedName: ?string,
239
239
  globalPrefix: string,
240
240
  }>,
241
- ): {|
241
+ ): {
242
242
  moduleCode: string,
243
243
  moduleMap: ?BasicSourceMap,
244
- |} {
244
+ } {
245
245
  const {file} = module;
246
246
  let moduleCode, moduleMap;
247
247
 
@@ -22,19 +22,19 @@ export type BuildResult = GraphResult;
22
22
  export type Callback<A = void, B = void> = (Error => void) &
23
23
  ((null | void, A, B) => void);
24
24
 
25
- export type Dependency = {|
25
+ export type Dependency = {
26
26
  // The module name or path used to require the dependency
27
27
  id: string,
28
28
  +isAsync: boolean,
29
29
  +isPrefetchOnly: boolean,
30
- +splitCondition: ?{|
30
+ +splitCondition: ?{
31
31
  +mobileConfigName: string,
32
- |},
32
+ },
33
33
  path: string,
34
34
  +locs: $ReadOnlyArray<BabelSourceLocation>,
35
- |};
35
+ };
36
36
 
37
- export type File = {|
37
+ export type File = {
38
38
  code: string,
39
39
  map: ?BasicSourceMap,
40
40
  functionMap: ?FBSourceFunctionMap,
@@ -42,7 +42,7 @@ export type File = {|
42
42
  type: CodeFileTypes,
43
43
  libraryIdx: ?number,
44
44
  soundResources?: ?Array<string>,
45
- |};
45
+ };
46
46
 
47
47
  type CodeFileTypes = 'module' | 'script';
48
48
 
@@ -51,11 +51,11 @@ export type GraphFn = (
51
51
  // platform: string,
52
52
  ) => GraphResult;
53
53
 
54
- export type GraphResult = {|
54
+ export type GraphResult = {
55
55
  modules: Array<Module>,
56
- |};
56
+ };
57
57
 
58
- export type ModuleIds = {|
58
+ export type ModuleIds = {
59
59
  /**
60
60
  * The module ID is global across all segments and identifies the module
61
61
  * uniquely. This is useful to cache modules that has been loaded already at
@@ -71,7 +71,7 @@ export type ModuleIds = {|
71
71
  * case this property does not apply and will be omitted.
72
72
  */
73
73
  +localId?: number,
74
- |};
74
+ };
75
75
 
76
76
  /**
77
77
  * Indempotent function that gets us the IDs corresponding to a particular
@@ -87,17 +87,17 @@ export type LoadResult = {
87
87
 
88
88
  export type LoadFn = (file: string) => LoadResult;
89
89
 
90
- export type Module = {|
90
+ export type Module = {
91
91
  dependencies: Array<Dependency>,
92
92
  file: File,
93
- |};
93
+ };
94
94
 
95
95
  export type PostProcessModules = (
96
96
  modules: $ReadOnlyArray<Module>,
97
97
  entryPoints: Array<string>,
98
98
  ) => $ReadOnlyArray<Module>;
99
99
 
100
- export type OutputFnArg = {|
100
+ export type OutputFnArg = {
101
101
  dependencyMapReservedName?: ?string,
102
102
  filename: string,
103
103
  globalPrefix: string,
@@ -107,22 +107,22 @@ export type OutputFnArg = {|
107
107
  sourceMapPath?: ?string,
108
108
  enableIDInlining: boolean,
109
109
  segmentID: number,
110
- |};
110
+ };
111
111
  export type OutputFn<M: MixedSourceMap = MixedSourceMap> =
112
112
  OutputFnArg => OutputResult<M>;
113
113
 
114
- export type OutputResult<M: MixedSourceMap> = {|
114
+ export type OutputResult<M: MixedSourceMap> = {
115
115
  code: string | Buffer,
116
116
  extraFiles?: Iterable<[string, string | Buffer]>,
117
117
  map: M,
118
- |};
118
+ };
119
119
 
120
- export type PackageData = {|
120
+ export type PackageData = {
121
121
  browser?: Object | string,
122
122
  main?: string,
123
123
  name?: string,
124
124
  'react-native'?: Object | string,
125
- |};
125
+ };
126
126
 
127
127
  export type ResolveFn = (id: string, source: ?string) => string;
128
128
 
@@ -159,16 +159,16 @@ export type TransformResults = {
159
159
 
160
160
  export type TransformVariants = {+[name: string]: {...}};
161
161
 
162
- export type TransformedCodeFile = {|
162
+ export type TransformedCodeFile = {
163
163
  +file: string,
164
164
  +functionMap: ?FBSourceFunctionMap,
165
165
  +hasteID: ?string,
166
166
  +package?: PackageData,
167
167
  +transformed: TransformResults,
168
168
  +type: CodeFileTypes,
169
- |};
169
+ };
170
170
 
171
- export type ImageSize = {|+width: number, +height: number|};
171
+ export type ImageSize = {+width: number, +height: number};
172
172
 
173
173
  export type AssetFileVariant = $ReadOnly<{
174
174
  /**
@@ -228,24 +228,24 @@ export type AssetFile = $ReadOnly<{
228
228
  }>;
229
229
 
230
230
  export type TransformedSourceFile =
231
- | {|
231
+ | {
232
232
  +type: 'code',
233
233
  +details: TransformedCodeFile,
234
- |}
235
- | {|
234
+ }
235
+ | {
236
236
  +type: 'asset',
237
237
  +details: AssetFile,
238
- |}
239
- | {|
238
+ }
239
+ | {
240
240
  +type: 'unknown',
241
- |};
241
+ };
242
242
 
243
- export type LibraryOptions = {|
243
+ export type LibraryOptions = {
244
244
  dependencies?: Array<string>,
245
245
  optimize: boolean,
246
246
  platform?: string,
247
247
  rebasePath: string => string,
248
- |};
248
+ };
249
249
 
250
250
  export type Base64Content = string;
251
251
  export type AssetContents = {
@@ -258,7 +258,7 @@ export type AssetContentsByPath = {
258
258
  ...
259
259
  };
260
260
 
261
- export type ResolvedCodeFile = {|
261
+ export type ResolvedCodeFile = {
262
262
  +codeFile: TransformedCodeFile,
263
263
  /**
264
264
  * Imagine we have a source file that contains a `require('foo')`. The library
@@ -267,35 +267,35 @@ export type ResolvedCodeFile = {|
267
267
  * `{'foo': 'bar/foo.js', 'bar': 'node_modules/bar/index.js'}`.
268
268
  */
269
269
  +filePathsByDependencyName: {[dependencyName: string]: string, ...},
270
- |};
270
+ };
271
271
 
272
- export type LibraryBoundCodeFile = {|
272
+ export type LibraryBoundCodeFile = {
273
273
  ...ResolvedCodeFile,
274
274
  /**
275
275
  * Index of the library that this code file has been exported from.
276
276
  */
277
277
  +libraryIdx: number,
278
- |};
278
+ };
279
279
 
280
280
  /**
281
281
  * Describe a set of JavaScript files and the associated assets. It could be
282
282
  * depending on modules from other libraries. To be able to resolve these
283
283
  * dependencies, these libraries need to be provided by callsites (ex. Buck).
284
284
  */
285
- export type Library = {|
285
+ export type Library = {
286
286
  +files: Array<TransformedCodeFile>,
287
287
  /* cannot be a Map because it's JSONified later on */
288
288
  +assets: AssetContentsByPath,
289
- |};
289
+ };
290
290
 
291
291
  /**
292
292
  * Just like a `Library`, but it also contains module resolutions. For example
293
293
  * if there is a `require('foo')` in some JavaScript file, we keep track of the
294
294
  * path it resolves to, ex. `beep/glo/foo.js`.
295
295
  */
296
- export type ResolvedLibrary = {|
296
+ export type ResolvedLibrary = {
297
297
  +files: $ReadOnlyArray<ResolvedCodeFile>,
298
298
  /* cannot be a Map because it's JSONified later on */
299
299
  +assets: AssetContentsByPath,
300
300
  +isPartiallyResolved?: boolean,
301
- |};
301
+ };
@@ -332,7 +332,7 @@ function processRequireCall<TSplitCondition>(
332
332
  }
333
333
 
334
334
  function getNearestLocFromPath(path: NodePath<>): ?BabelSourceLocation {
335
- let current = path;
335
+ let current: ?(NodePath<> | NodePath<BabelNode>) = path;
336
336
  while (current && !current.node.loc) {
337
337
  current = current.parentPath;
338
338
  }
@@ -383,7 +383,7 @@ function isOptionalDependency<TSplitCondition>(
383
383
 
384
384
  // Valid statement stack for single-level try-block: expressionStatement -> blockStatement -> tryStatement
385
385
  let sCount = 0;
386
- let p = path;
386
+ let p: ?(NodePath<> | NodePath<BabelNode>) = path;
387
387
  while (p && sCount < 3) {
388
388
  if (p.isStatement()) {
389
389
  if (p.node.type === 'BlockStatement') {
@@ -35,7 +35,7 @@ export type StackFrameOutput = $ReadOnly<{
35
35
  ...
36
36
  }>;
37
37
  type ExplodedSourceMapModule = $ElementType<ExplodedSourceMap, number>;
38
- type Position = {|+line1Based: number, column0Based: number|};
38
+ type Position = {+line1Based: number, column0Based: number};
39
39
 
40
40
  function createFunctionNameGetter(
41
41
  module: ExplodedSourceMapModule,
@@ -81,7 +81,7 @@ export type BundleMetadata = {
81
81
  ...
82
82
  };
83
83
 
84
- type ProcessStartContext = {|
84
+ type ProcessStartContext = {
85
85
  +buildID: string,
86
86
  +bundleOptions: BundleOptions,
87
87
  +graphId: GraphId,
@@ -91,24 +91,24 @@ type ProcessStartContext = {|
91
91
  +req: IncomingMessage,
92
92
  +revisionId?: ?RevisionId,
93
93
  ...SplitBundleOptions,
94
- |};
94
+ };
95
95
 
96
- type ProcessDeleteContext = {|
96
+ type ProcessDeleteContext = {
97
97
  +graphId: GraphId,
98
98
  +req: IncomingMessage,
99
99
  +res: ServerResponse,
100
- |};
100
+ };
101
101
 
102
- type ProcessEndContext<T> = {|
102
+ type ProcessEndContext<T> = {
103
103
  ...ProcessStartContext,
104
104
  +result: T,
105
- |};
105
+ };
106
106
 
107
- export type ServerOptions = $ReadOnly<{|
107
+ export type ServerOptions = $ReadOnly<{
108
108
  hasReducedPerformance?: boolean,
109
109
  onBundleBuilt?: (bundlePath: string) => void,
110
110
  watch?: boolean,
111
- |}>;
111
+ }>;
112
112
 
113
113
  const DELTA_ID_HEADER = 'X-Metro-Delta-ID';
114
114
  const FILES_CHANGED_COUNT_HEADER = 'X-Metro-Files-Changed-Count';
@@ -504,7 +504,7 @@ class Server {
504
504
  build,
505
505
  delete: deleteFn,
506
506
  finish,
507
- }: {|
507
+ }: {
508
508
  +createStartEntry: (context: ProcessStartContext) => ActionLogEntryData,
509
509
  +createEndEntry: (
510
510
  context: ProcessEndContext<T>,
@@ -512,7 +512,7 @@ class Server {
512
512
  +build: (context: ProcessStartContext) => Promise<T>,
513
513
  +delete?: (context: ProcessDeleteContext) => Promise<void>,
514
514
  +finish: (context: ProcessEndContext<T>) => void,
515
- |}) {
515
+ }) {
516
516
  return async function requestProcessor(
517
517
  req: IncomingMessage,
518
518
  res: ServerResponse,
@@ -703,12 +703,12 @@ class Server {
703
703
  };
704
704
  },
705
705
  createEndEntry(
706
- context: ProcessEndContext<{|
706
+ context: ProcessEndContext<{
707
707
  bundle: string,
708
708
  lastModifiedDate: Date,
709
709
  nextRevId: RevisionId,
710
710
  numModifiedFiles: number,
711
- |}>,
711
+ }>,
712
712
  ) {
713
713
  return {
714
714
  outdated_modules: context.result.numModifiedFiles,
@@ -820,12 +820,12 @@ class Server {
820
820
  };
821
821
  },
822
822
  createEndEntry(
823
- context: ProcessEndContext<{|
823
+ context: ProcessEndContext<{
824
824
  bytecode: Buffer,
825
825
  lastModifiedDate: Date,
826
826
  nextRevId: RevisionId,
827
827
  numModifiedFiles: number,
828
- |}>,
828
+ }>,
829
829
  ) {
830
830
  return {
831
831
  outdated_modules: context.result.numModifiedFiles,
@@ -1193,14 +1193,14 @@ class Server {
1193
1193
  return this._config.watchFolders;
1194
1194
  }
1195
1195
 
1196
- static DEFAULT_GRAPH_OPTIONS: {|
1196
+ static DEFAULT_GRAPH_OPTIONS: {
1197
1197
  customTransformOptions: any,
1198
1198
  dev: boolean,
1199
1199
  hot: boolean,
1200
1200
  minify: boolean,
1201
1201
  runtimeBytecodeVersion: ?number,
1202
1202
  unstable_transformProfile: 'default',
1203
- |} = {
1203
+ } = {
1204
1204
  customTransformOptions: Object.create(null),
1205
1205
  dev: true,
1206
1206
  hot: false,
@@ -1209,7 +1209,7 @@ class Server {
1209
1209
  unstable_transformProfile: 'default',
1210
1210
  };
1211
1211
 
1212
- static DEFAULT_BUNDLE_OPTIONS: {|
1212
+ static DEFAULT_BUNDLE_OPTIONS: {
1213
1213
  ...typeof Server.DEFAULT_GRAPH_OPTIONS,
1214
1214
  excludeSource: false,
1215
1215
  inlineSourceMap: false,
@@ -1219,7 +1219,7 @@ class Server {
1219
1219
  shallow: false,
1220
1220
  sourceMapUrl: null,
1221
1221
  sourceUrl: null,
1222
- |} = {
1222
+ } = {
1223
1223
  ...Server.DEFAULT_GRAPH_OPTIONS,
1224
1224
  excludeSource: false,
1225
1225
  inlineSourceMap: false,
@@ -23,12 +23,12 @@ const {Terminal} = require('metro-core');
23
23
  const term = new Terminal(process.stdout);
24
24
  const updateReporter = new TerminalReporter(term);
25
25
 
26
- module.exports = (): ({|
26
+ module.exports = (): ({
27
27
  builder: (yargs: Yargs) => void,
28
28
  command: string,
29
29
  description: string,
30
30
  handler: (argv: YargArguments) => void,
31
- |}) => ({
31
+ }) => ({
32
32
  command: 'build <entry>',
33
33
 
34
34
  description:
@@ -19,12 +19,12 @@ const MetroApi = require('../index');
19
19
  const {loadConfig, resolveConfig} = require('metro-config');
20
20
  const {promisify} = require('util');
21
21
 
22
- module.exports = (): ({|
22
+ module.exports = (): ({
23
23
  builder: (yargs: Yargs) => void,
24
24
  command: $TEMPORARY$string<'serve'>,
25
25
  description: string,
26
26
  handler: (argv: YargArguments) => void,
27
- |}) => ({
27
+ }) => ({
28
28
  command: 'serve',
29
29
 
30
30
  description: 'Starts Metro on the given port, building bundles on the fly',