metro 0.70.2 → 0.71.1
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.
- package/package.json +22 -21
- package/src/Assets.js.flow +4 -4
- package/src/Bundler/util.js +1 -1
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.js +17 -10
- package/src/Bundler.js.flow +19 -14
- package/src/DeltaBundler/DeltaCalculator.js +13 -17
- package/src/DeltaBundler/DeltaCalculator.js.flow +15 -20
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +2 -2
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +2 -2
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Worker.flow.js +78 -0
- package/src/DeltaBundler/Worker.flow.js.flow +121 -0
- package/src/DeltaBundler/Worker.js +8 -66
- package/src/DeltaBundler/Worker.js.flow +8 -107
- package/src/DeltaBundler/WorkerFarm.js.flow +4 -4
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +4 -0
- package/src/DeltaBundler/getTransformCacheKey.js.flow +2 -2
- package/src/DeltaBundler/graphOperations.js +634 -0
- package/src/DeltaBundler/graphOperations.js.flow +749 -0
- package/src/DeltaBundler/types.flow.js.flow +36 -30
- package/src/DeltaBundler.js +14 -6
- package/src/DeltaBundler.js.flow +14 -10
- package/src/HmrServer.js.flow +6 -6
- package/src/IncrementalBundler.js +1 -1
- package/src/IncrementalBundler.js.flow +8 -8
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +2 -2
- package/src/ModuleGraph/node-haste/node-haste.js +4 -4
- package/src/ModuleGraph/node-haste/node-haste.js.flow +13 -7
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +2 -2
- package/src/ModuleGraph/output/plain-bundle.js.flow +2 -2
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +8 -8
- package/src/ModuleGraph/output/util.js.flow +2 -2
- package/src/ModuleGraph/types.flow.js.flow +37 -37
- package/src/ModuleGraph/worker/collectDependencies.js.flow +2 -2
- package/src/Server/symbolicate.js.flow +1 -1
- package/src/Server.js.flow +18 -18
- package/src/cli.js +5 -0
- package/src/cli.js.flow +5 -0
- package/src/commands/build.js +4 -3
- package/src/commands/build.js.flow +5 -3
- package/src/commands/serve.js +3 -3
- package/src/commands/serve.js.flow +5 -3
- package/src/index.flow.js +392 -0
- package/src/index.flow.js.flow +480 -0
- package/src/index.js +8 -366
- package/src/index.js.flow +8 -456
- package/src/lib/bundleToBytecode.js.flow +2 -2
- package/src/lib/bundleToString.js.flow +2 -2
- package/src/lib/getPreludeCode.js.flow +2 -2
- package/src/lib/transformHelpers.js.flow +2 -2
- package/src/node-haste/DependencyGraph/ModuleResolution.js +17 -4
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +20 -12
- package/src/node-haste/DependencyGraph/createHasteMap.js +79 -19
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +15 -14
- package/src/node-haste/DependencyGraph.js +31 -27
- package/src/node-haste/DependencyGraph.js.flow +43 -37
- package/src/node-haste/ModuleCache.js.flow +1 -1
- package/src/node-haste/lib/AssetPaths.js.flow +2 -2
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +1 -1
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +2 -2
- package/src/shared/types.flow.js.flow +14 -14
- package/src/DeltaBundler/computeDelta.js +0 -42
- package/src/DeltaBundler/computeDelta.js.flow +0 -47
- package/src/DeltaBundler/traverseDependencies.js +0 -470
- package/src/DeltaBundler/traverseDependencies.js.flow +0 -565
- package/src/node-haste/DependencyGraph/types.js +0 -10
- package/src/node-haste/DependencyGraph/types.js.flow +0 -88
|
@@ -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 = {
|
|
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 = {
|
|
38
|
+
type Position = {+line1Based: number, column0Based: number};
|
|
39
39
|
|
|
40
40
|
function createFunctionNameGetter(
|
|
41
41
|
module: ExplodedSourceMapModule,
|
package/src/Server.js.flow
CHANGED
|
@@ -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,
|
package/src/cli.js
CHANGED
package/src/cli.js.flow
CHANGED
package/src/commands/build.js
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
const { makeAsyncCommand } = require("../cli-utils");
|
|
13
13
|
|
|
14
|
-
const MetroApi = require("../index");
|
|
15
|
-
|
|
16
14
|
const TerminalReporter = require("../lib/TerminalReporter");
|
|
17
15
|
|
|
18
16
|
const { loadConfig } = require("metro-config");
|
|
@@ -78,7 +76,10 @@ module.exports = () => ({
|
|
|
78
76
|
handler: makeAsyncCommand(async (argv) => {
|
|
79
77
|
const config = await loadConfig(argv); // $FlowExpectedError YargArguments and RunBuildOptions are used interchangeable but their types are not yet compatible
|
|
80
78
|
|
|
81
|
-
const options = argv;
|
|
79
|
+
const options = argv; // Inline require() to avoid circular dependency with ../index
|
|
80
|
+
|
|
81
|
+
const MetroApi = require("../index");
|
|
82
|
+
|
|
82
83
|
await MetroApi.runBuild(config, {
|
|
83
84
|
...options,
|
|
84
85
|
onBegin: () => {
|
|
@@ -15,7 +15,6 @@ import type {YargArguments} from 'metro-config/src/configTypes.flow';
|
|
|
15
15
|
import typeof Yargs from 'yargs';
|
|
16
16
|
|
|
17
17
|
const {makeAsyncCommand} = require('../cli-utils');
|
|
18
|
-
const MetroApi = require('../index');
|
|
19
18
|
const TerminalReporter = require('../lib/TerminalReporter');
|
|
20
19
|
const {loadConfig} = require('metro-config');
|
|
21
20
|
const {Terminal} = require('metro-core');
|
|
@@ -23,12 +22,12 @@ const {Terminal} = require('metro-core');
|
|
|
23
22
|
const term = new Terminal(process.stdout);
|
|
24
23
|
const updateReporter = new TerminalReporter(term);
|
|
25
24
|
|
|
26
|
-
module.exports = (): ({
|
|
25
|
+
module.exports = (): ({
|
|
27
26
|
builder: (yargs: Yargs) => void,
|
|
28
27
|
command: string,
|
|
29
28
|
description: string,
|
|
30
29
|
handler: (argv: YargArguments) => void,
|
|
31
|
-
|
|
30
|
+
}) => ({
|
|
32
31
|
command: 'build <entry>',
|
|
33
32
|
|
|
34
33
|
description:
|
|
@@ -66,6 +65,9 @@ module.exports = (): ({|
|
|
|
66
65
|
// $FlowExpectedError YargArguments and RunBuildOptions are used interchangeable but their types are not yet compatible
|
|
67
66
|
const options = (argv: RunBuildOptions);
|
|
68
67
|
|
|
68
|
+
// Inline require() to avoid circular dependency with ../index
|
|
69
|
+
const MetroApi = require('../index');
|
|
70
|
+
|
|
69
71
|
await MetroApi.runBuild(config, {
|
|
70
72
|
...options,
|
|
71
73
|
onBegin: (): void => {
|
package/src/commands/serve.js
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
const { makeAsyncCommand, watchFile } = require("../cli-utils");
|
|
13
13
|
|
|
14
|
-
const MetroApi = require("../index");
|
|
15
|
-
|
|
16
14
|
const { loadConfig, resolveConfig } = require("metro-config");
|
|
17
15
|
|
|
18
16
|
const { promisify } = require("util");
|
|
@@ -93,7 +91,9 @@ module.exports = () => ({
|
|
|
93
91
|
await promisify(server.close).call(server);
|
|
94
92
|
}
|
|
95
93
|
|
|
96
|
-
const config = await loadConfig(argv); //
|
|
94
|
+
const config = await loadConfig(argv); // Inline require() to avoid circular dependency with ../index
|
|
95
|
+
|
|
96
|
+
const MetroApi = require("../index"); // $FlowExpectedError YargArguments and RunBuildOptions are used interchangeable but their types are not yet compatible
|
|
97
97
|
|
|
98
98
|
server = await MetroApi.runServer(config, argv);
|
|
99
99
|
restarting = false;
|
|
@@ -15,16 +15,15 @@ import type {YargArguments} from 'metro-config/src/configTypes.flow';
|
|
|
15
15
|
import typeof Yargs from 'yargs';
|
|
16
16
|
|
|
17
17
|
const {makeAsyncCommand, watchFile} = require('../cli-utils');
|
|
18
|
-
const MetroApi = require('../index');
|
|
19
18
|
const {loadConfig, resolveConfig} = require('metro-config');
|
|
20
19
|
const {promisify} = require('util');
|
|
21
20
|
|
|
22
|
-
module.exports = (): ({
|
|
21
|
+
module.exports = (): ({
|
|
23
22
|
builder: (yargs: Yargs) => void,
|
|
24
23
|
command: $TEMPORARY$string<'serve'>,
|
|
25
24
|
description: string,
|
|
26
25
|
handler: (argv: YargArguments) => void,
|
|
27
|
-
|
|
26
|
+
}) => ({
|
|
28
27
|
command: 'serve',
|
|
29
28
|
|
|
30
29
|
description: 'Starts Metro on the given port, building bundles on the fly',
|
|
@@ -84,6 +83,9 @@ module.exports = (): ({|
|
|
|
84
83
|
|
|
85
84
|
const config = await loadConfig(argv);
|
|
86
85
|
|
|
86
|
+
// Inline require() to avoid circular dependency with ../index
|
|
87
|
+
const MetroApi = require('../index');
|
|
88
|
+
|
|
87
89
|
// $FlowExpectedError YargArguments and RunBuildOptions are used interchangeable but their types are not yet compatible
|
|
88
90
|
server = await MetroApi.runServer(config, (argv: RunServerOptions));
|
|
89
91
|
|