metro 0.72.1 → 0.72.3
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 +23 -21
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +3 -2
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +2 -1
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +2 -1
- package/src/DeltaBundler/Worker.js +0 -1
- package/src/DeltaBundler/Worker.js.flow +0 -1
- package/src/DeltaBundler/graphOperations.js +6 -6
- package/src/DeltaBundler/graphOperations.js.flow +5 -5
- package/src/DeltaBundler.js.flow +1 -1
- package/src/HmrServer.js +9 -5
- package/src/HmrServer.js.flow +9 -4
- package/src/IncrementalBundler.js +16 -4
- package/src/IncrementalBundler.js.flow +17 -4
- package/src/ModuleGraph/node-haste/HasteFS.js +0 -1
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +0 -1
- package/src/ModuleGraph/node-haste/Package.js.flow +5 -5
- package/src/ModuleGraph/node-haste/node-haste.js +8 -4
- package/src/ModuleGraph/node-haste/node-haste.js.flow +21 -14
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +1 -2
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +0 -1
- package/src/ModuleGraph/output/util.js +2 -4
- package/src/ModuleGraph/output/util.js.flow +1 -2
- package/src/ModuleGraph/types.flow.js.flow +28 -6
- package/src/Server/MultipartResponse.js +10 -12
- package/src/Server/MultipartResponse.js.flow +97 -0
- package/src/Server.js +100 -48
- package/src/Server.js.flow +118 -49
- package/src/index.flow.js +16 -8
- package/src/index.flow.js.flow +14 -8
- package/src/index.js +0 -1
- package/src/index.js.flow +0 -1
- package/src/lib/CountingSet.js +0 -1
- package/src/lib/CountingSet.js.flow +0 -1
- package/src/lib/RamBundleParser.js +1 -0
- package/src/lib/RamBundleParser.js.flow +1 -0
- package/src/lib/TerminalReporter.js +22 -24
- package/src/lib/TerminalReporter.js.flow +20 -24
- package/src/lib/bundleToBytecode.js +3 -2
- package/src/lib/bundleToBytecode.js.flow +2 -2
- package/src/lib/getGraphId.js +16 -3
- package/src/lib/getGraphId.js.flow +10 -10
- package/src/lib/getPrependedScripts.js +13 -5
- package/src/lib/getPrependedScripts.js.flow +6 -1
- package/src/lib/parseCustomResolverOptions.js +26 -0
- package/src/lib/parseCustomResolverOptions.js.flow +38 -0
- package/src/lib/parseOptionsFromUrl.js +3 -0
- package/src/lib/parseOptionsFromUrl.js.flow +2 -0
- package/src/lib/splitBundleOptions.js +3 -0
- package/src/lib/splitBundleOptions.js.flow +3 -0
- package/src/lib/transformHelpers.js +27 -13
- package/src/lib/transformHelpers.js.flow +27 -7
- package/src/node-haste/DependencyGraph/ModuleResolution.js +18 -2
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +5 -0
- package/src/node-haste/DependencyGraph.js +34 -9
- package/src/node-haste/DependencyGraph.js.flow +49 -11
- package/src/node-haste/Module.js +1 -0
- package/src/node-haste/Module.js.flow +1 -0
- package/src/node-haste/Package.js +0 -1
- package/src/node-haste/Package.js.flow +0 -1
- package/src/shared/output/bundle.js +0 -1
- package/src/shared/output/bundle.js.flow +0 -1
- package/src/shared/types.flow.js.flow +7 -0
package/src/Server.js.flow
CHANGED
|
@@ -26,6 +26,7 @@ import type {Reporter} from './lib/reporting';
|
|
|
26
26
|
import type {
|
|
27
27
|
BundleOptions,
|
|
28
28
|
GraphOptions,
|
|
29
|
+
ResolverInputOptions,
|
|
29
30
|
SplitBundleOptions,
|
|
30
31
|
} from './shared/types.flow';
|
|
31
32
|
import type {IncomingMessage, ServerResponse} from 'http';
|
|
@@ -36,6 +37,8 @@ import type {
|
|
|
36
37
|
ActionStartLogEntry,
|
|
37
38
|
LogEntry,
|
|
38
39
|
} from 'metro-core/src/Logger';
|
|
40
|
+
import type {CustomResolverOptions} from 'metro-resolver/src/types';
|
|
41
|
+
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
39
42
|
|
|
40
43
|
const {getAsset} = require('./Assets');
|
|
41
44
|
const baseBytecodeBundle = require('./DeltaBundler/Serializers/baseBytecodeBundle');
|
|
@@ -57,16 +60,16 @@ const parseOptionsFromUrl = require('./lib/parseOptionsFromUrl');
|
|
|
57
60
|
const splitBundleOptions = require('./lib/splitBundleOptions');
|
|
58
61
|
const transformHelpers = require('./lib/transformHelpers');
|
|
59
62
|
const parsePlatformFilePath = require('./node-haste/lib/parsePlatformFilePath');
|
|
60
|
-
const MultipartResponse = require('./Server/MultipartResponse');
|
|
61
63
|
const symbolicate = require('./Server/symbolicate');
|
|
62
64
|
const {codeFrameColumns} = require('@babel/code-frame');
|
|
65
|
+
const MultipartResponse = require('./Server/MultipartResponse');
|
|
63
66
|
const debug = require('debug')('Metro:Server');
|
|
64
67
|
const fs = require('graceful-fs');
|
|
65
68
|
const {
|
|
66
69
|
Logger,
|
|
67
70
|
Logger: {createActionStartEntry, createActionEndEntry, log},
|
|
68
71
|
} = require('metro-core');
|
|
69
|
-
|
|
72
|
+
|
|
70
73
|
const mime = require('mime-types');
|
|
71
74
|
const nullthrows = require('nullthrows');
|
|
72
75
|
const path = require('path');
|
|
@@ -88,8 +91,7 @@ type ProcessStartContext = {
|
|
|
88
91
|
+bundleOptions: BundleOptions,
|
|
89
92
|
+graphId: GraphId,
|
|
90
93
|
+graphOptions: GraphOptions,
|
|
91
|
-
|
|
92
|
-
+mres: MultipartResponse,
|
|
94
|
+
+mres: MultipartResponse | ServerResponse,
|
|
93
95
|
+req: IncomingMessage,
|
|
94
96
|
+revisionId?: ?RevisionId,
|
|
95
97
|
...SplitBundleOptions,
|
|
@@ -115,6 +117,10 @@ export type ServerOptions = $ReadOnly<{
|
|
|
115
117
|
const DELTA_ID_HEADER = 'X-Metro-Delta-ID';
|
|
116
118
|
const FILES_CHANGED_COUNT_HEADER = 'X-Metro-Files-Changed-Count';
|
|
117
119
|
|
|
120
|
+
function getBytecodeVersion() {
|
|
121
|
+
return require('metro-hermes-compiler').VERSION;
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
class Server {
|
|
119
125
|
_bundler: IncrementalBundler;
|
|
120
126
|
_config: ConfigT;
|
|
@@ -178,6 +184,7 @@ class Server {
|
|
|
178
184
|
entryFile,
|
|
179
185
|
graphOptions,
|
|
180
186
|
onProgress,
|
|
187
|
+
resolverOptions,
|
|
181
188
|
serializerOptions,
|
|
182
189
|
transformOptions,
|
|
183
190
|
} = splitBundleOptions(options);
|
|
@@ -185,6 +192,7 @@ class Server {
|
|
|
185
192
|
const {prepend, graph} = await this._bundler.buildGraph(
|
|
186
193
|
entryFile,
|
|
187
194
|
transformOptions,
|
|
195
|
+
resolverOptions,
|
|
188
196
|
{
|
|
189
197
|
onProgress,
|
|
190
198
|
shallow: graphOptions.shallow,
|
|
@@ -196,7 +204,11 @@ class Server {
|
|
|
196
204
|
const bundleOptions = {
|
|
197
205
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
198
206
|
this._config.transformer.asyncRequireModulePath,
|
|
199
|
-
{
|
|
207
|
+
{
|
|
208
|
+
relativeTo: 'project',
|
|
209
|
+
resolverOptions,
|
|
210
|
+
transformOptions,
|
|
211
|
+
},
|
|
200
212
|
),
|
|
201
213
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
202
214
|
createModuleId: this._createModuleId,
|
|
@@ -255,6 +267,7 @@ class Server {
|
|
|
255
267
|
entryFile,
|
|
256
268
|
graphOptions,
|
|
257
269
|
onProgress,
|
|
270
|
+
resolverOptions,
|
|
258
271
|
serializerOptions,
|
|
259
272
|
transformOptions,
|
|
260
273
|
} = splitBundleOptions(options);
|
|
@@ -262,6 +275,7 @@ class Server {
|
|
|
262
275
|
const {prepend, graph} = await this._bundler.buildGraph(
|
|
263
276
|
entryFile,
|
|
264
277
|
transformOptions,
|
|
278
|
+
resolverOptions,
|
|
265
279
|
{onProgress, shallow: graphOptions.shallow},
|
|
266
280
|
);
|
|
267
281
|
|
|
@@ -270,7 +284,11 @@ class Server {
|
|
|
270
284
|
return await getRamBundleInfo(entryPoint, prepend, graph, {
|
|
271
285
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
272
286
|
this._config.transformer.asyncRequireModulePath,
|
|
273
|
-
{
|
|
287
|
+
{
|
|
288
|
+
relativeTo: 'project',
|
|
289
|
+
resolverOptions,
|
|
290
|
+
transformOptions,
|
|
291
|
+
},
|
|
274
292
|
),
|
|
275
293
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
276
294
|
createModuleId: this._createModuleId,
|
|
@@ -295,12 +313,13 @@ class Server {
|
|
|
295
313
|
}
|
|
296
314
|
|
|
297
315
|
async getAssets(options: BundleOptions): Promise<$ReadOnlyArray<AssetData>> {
|
|
298
|
-
const {entryFile,
|
|
316
|
+
const {entryFile, onProgress, resolverOptions, transformOptions} =
|
|
299
317
|
splitBundleOptions(options);
|
|
300
318
|
|
|
301
319
|
const dependencies = await this._bundler.getDependencies(
|
|
302
320
|
[entryFile],
|
|
303
321
|
transformOptions,
|
|
322
|
+
resolverOptions,
|
|
304
323
|
{onProgress, shallow: false},
|
|
305
324
|
);
|
|
306
325
|
|
|
@@ -320,10 +339,15 @@ class Server {
|
|
|
320
339
|
+platform: string,
|
|
321
340
|
...
|
|
322
341
|
}): Promise<Array<string>> {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
342
|
+
const {
|
|
343
|
+
entryFile,
|
|
344
|
+
onProgress,
|
|
345
|
+
resolverOptions,
|
|
346
|
+
transformOptions,
|
|
347
|
+
/* $FlowFixMe(>=0.122.0 site=react_native_fb) This comment suppresses an
|
|
348
|
+
* error found when Flow v0.122.0 was deployed. To see the error, delete
|
|
349
|
+
* this comment and run Flow. */
|
|
350
|
+
} = splitBundleOptions({
|
|
327
351
|
...Server.DEFAULT_BUNDLE_OPTIONS,
|
|
328
352
|
...options,
|
|
329
353
|
bundleType: 'bundle',
|
|
@@ -332,6 +356,7 @@ class Server {
|
|
|
332
356
|
const {prepend, graph} = await this._bundler.buildGraph(
|
|
333
357
|
entryFile,
|
|
334
358
|
transformOptions,
|
|
359
|
+
resolverOptions,
|
|
335
360
|
{onProgress, shallow: false},
|
|
336
361
|
);
|
|
337
362
|
|
|
@@ -445,7 +470,7 @@ class Server {
|
|
|
445
470
|
return parseOptionsFromUrl(
|
|
446
471
|
url,
|
|
447
472
|
new Set(this._config.resolver.platforms),
|
|
448
|
-
|
|
473
|
+
getBytecodeVersion(),
|
|
449
474
|
);
|
|
450
475
|
}
|
|
451
476
|
|
|
@@ -522,30 +547,36 @@ class Server {
|
|
|
522
547
|
res: ServerResponse,
|
|
523
548
|
bundleOptions: BundleOptions,
|
|
524
549
|
) => Promise<void> {
|
|
525
|
-
/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by
|
|
526
|
-
* Flow's LTI update could not be added via codemod */
|
|
527
550
|
return async function requestProcessor(
|
|
551
|
+
this: Server,
|
|
528
552
|
req: IncomingMessage,
|
|
529
553
|
res: ServerResponse,
|
|
530
554
|
bundleOptions: BundleOptions,
|
|
531
555
|
): Promise<void> {
|
|
532
|
-
const {
|
|
533
|
-
|
|
556
|
+
const {
|
|
557
|
+
entryFile,
|
|
558
|
+
graphOptions,
|
|
559
|
+
resolverOptions,
|
|
560
|
+
serializerOptions,
|
|
561
|
+
transformOptions,
|
|
562
|
+
} = splitBundleOptions(bundleOptions);
|
|
534
563
|
|
|
535
564
|
/**
|
|
536
565
|
* `entryFile` is relative to projectRoot, we need to use resolution function
|
|
537
566
|
* to find the appropriate file with supported extensions.
|
|
538
567
|
*/
|
|
539
568
|
const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
|
|
540
|
-
transformOptions,
|
|
541
569
|
relativeTo: 'server',
|
|
570
|
+
resolverOptions,
|
|
571
|
+
transformOptions,
|
|
542
572
|
});
|
|
543
573
|
const graphId = getGraphId(resolvedEntryFilePath, transformOptions, {
|
|
544
|
-
shallow: graphOptions.shallow,
|
|
545
574
|
experimentalImportBundleSupport:
|
|
546
575
|
this._config.transformer.experimentalImportBundleSupport,
|
|
547
576
|
unstable_allowRequireContext:
|
|
548
577
|
this._config.transformer.unstable_allowRequireContext,
|
|
578
|
+
resolverOptions,
|
|
579
|
+
shallow: graphOptions.shallow,
|
|
549
580
|
});
|
|
550
581
|
|
|
551
582
|
// For resources that support deletion, handle the DELETE method.
|
|
@@ -569,7 +600,7 @@ class Server {
|
|
|
569
600
|
return;
|
|
570
601
|
}
|
|
571
602
|
|
|
572
|
-
const mres = MultipartResponse.
|
|
603
|
+
const mres = MultipartResponse.wrapIfSupported(req, res);
|
|
573
604
|
const buildID = this.getNewBuildID();
|
|
574
605
|
|
|
575
606
|
let onProgress = null;
|
|
@@ -586,13 +617,15 @@ class Server {
|
|
|
586
617
|
// that, we check the percentage, and only send percentages that are
|
|
587
618
|
// actually different and that have increased from the last one we sent.
|
|
588
619
|
if (currentProgress > lastProgress || totalFileCount < 10) {
|
|
589
|
-
mres
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
620
|
+
if (mres instanceof MultipartResponse) {
|
|
621
|
+
mres.writeChunk(
|
|
622
|
+
{'Content-Type': 'application/json'},
|
|
623
|
+
JSON.stringify({
|
|
624
|
+
done: transformedFileCount,
|
|
625
|
+
total: totalFileCount,
|
|
626
|
+
}),
|
|
627
|
+
);
|
|
628
|
+
}
|
|
596
629
|
|
|
597
630
|
// The `uncork` called internally in Node via `promise.nextTick()` may not fire
|
|
598
631
|
// until all of the Promises are resolved because the microtask queue we're
|
|
@@ -639,6 +672,7 @@ class Server {
|
|
|
639
672
|
mres,
|
|
640
673
|
onProgress,
|
|
641
674
|
req,
|
|
675
|
+
resolverOptions,
|
|
642
676
|
serializerOptions,
|
|
643
677
|
transformOptions,
|
|
644
678
|
};
|
|
@@ -736,6 +770,7 @@ class Server {
|
|
|
736
770
|
graphId,
|
|
737
771
|
graphOptions,
|
|
738
772
|
onProgress,
|
|
773
|
+
resolverOptions,
|
|
739
774
|
serializerOptions,
|
|
740
775
|
transformOptions,
|
|
741
776
|
}) => {
|
|
@@ -743,15 +778,18 @@ class Server {
|
|
|
743
778
|
|
|
744
779
|
const {delta, revision} = await (revPromise != null
|
|
745
780
|
? this._bundler.updateGraph(await revPromise, false)
|
|
746
|
-
: this._bundler.initializeGraph(
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
781
|
+
: this._bundler.initializeGraph(
|
|
782
|
+
entryFile,
|
|
783
|
+
transformOptions,
|
|
784
|
+
resolverOptions,
|
|
785
|
+
{
|
|
786
|
+
onProgress,
|
|
787
|
+
shallow: graphOptions.shallow,
|
|
788
|
+
},
|
|
789
|
+
));
|
|
750
790
|
|
|
751
791
|
const serializer =
|
|
752
792
|
this._config.serializer.customSerializer ||
|
|
753
|
-
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by
|
|
754
|
-
* Flow's LTI update could not be added via codemod */
|
|
755
793
|
((...args) => bundleToString(baseJSBundle(...args)).code);
|
|
756
794
|
|
|
757
795
|
const bundle = await serializer(
|
|
@@ -761,7 +799,11 @@ class Server {
|
|
|
761
799
|
{
|
|
762
800
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
763
801
|
this._config.transformer.asyncRequireModulePath,
|
|
764
|
-
{
|
|
802
|
+
{
|
|
803
|
+
relativeTo: 'project',
|
|
804
|
+
resolverOptions,
|
|
805
|
+
transformOptions,
|
|
806
|
+
},
|
|
765
807
|
),
|
|
766
808
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
767
809
|
createModuleId: this._createModuleId,
|
|
@@ -859,6 +901,7 @@ class Server {
|
|
|
859
901
|
graphId,
|
|
860
902
|
graphOptions,
|
|
861
903
|
onProgress,
|
|
904
|
+
resolverOptions,
|
|
862
905
|
serializerOptions,
|
|
863
906
|
transformOptions,
|
|
864
907
|
}) => {
|
|
@@ -866,16 +909,25 @@ class Server {
|
|
|
866
909
|
|
|
867
910
|
const {delta, revision} = await (revPromise != null
|
|
868
911
|
? this._bundler.updateGraph(await revPromise, false)
|
|
869
|
-
: this._bundler.initializeGraph(
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
912
|
+
: this._bundler.initializeGraph(
|
|
913
|
+
entryFile,
|
|
914
|
+
transformOptions,
|
|
915
|
+
resolverOptions,
|
|
916
|
+
{
|
|
917
|
+
onProgress,
|
|
918
|
+
shallow: graphOptions.shallow,
|
|
919
|
+
},
|
|
920
|
+
));
|
|
873
921
|
|
|
874
922
|
const bundle = bundleToBytecode(
|
|
875
923
|
baseBytecodeBundle(entryFile, revision.prepend, revision.graph, {
|
|
876
924
|
asyncRequireModulePath: await this._resolveRelativePath(
|
|
877
925
|
this._config.transformer.asyncRequireModulePath,
|
|
878
|
-
{
|
|
926
|
+
{
|
|
927
|
+
relativeTo: 'project',
|
|
928
|
+
resolverOptions,
|
|
929
|
+
transformOptions,
|
|
930
|
+
},
|
|
879
931
|
),
|
|
880
932
|
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
881
933
|
createModuleId: this._createModuleId,
|
|
@@ -971,6 +1023,7 @@ class Server {
|
|
|
971
1023
|
graphId,
|
|
972
1024
|
graphOptions,
|
|
973
1025
|
onProgress,
|
|
1026
|
+
resolverOptions,
|
|
974
1027
|
serializerOptions,
|
|
975
1028
|
transformOptions,
|
|
976
1029
|
}) => {
|
|
@@ -980,6 +1033,7 @@ class Server {
|
|
|
980
1033
|
({revision} = await this._bundler.initializeGraph(
|
|
981
1034
|
entryFile,
|
|
982
1035
|
transformOptions,
|
|
1036
|
+
resolverOptions,
|
|
983
1037
|
{onProgress, shallow: graphOptions.shallow},
|
|
984
1038
|
));
|
|
985
1039
|
} else {
|
|
@@ -1020,10 +1074,16 @@ class Server {
|
|
|
1020
1074
|
bundler: 'delta',
|
|
1021
1075
|
};
|
|
1022
1076
|
},
|
|
1023
|
-
build: async ({
|
|
1077
|
+
build: async ({
|
|
1078
|
+
entryFile,
|
|
1079
|
+
onProgress,
|
|
1080
|
+
resolverOptions,
|
|
1081
|
+
transformOptions,
|
|
1082
|
+
}) => {
|
|
1024
1083
|
const dependencies = await this._bundler.getDependencies(
|
|
1025
1084
|
[entryFile],
|
|
1026
1085
|
transformOptions,
|
|
1086
|
+
resolverOptions,
|
|
1027
1087
|
{onProgress, shallow: false},
|
|
1028
1088
|
);
|
|
1029
1089
|
|
|
@@ -1144,15 +1204,16 @@ class Server {
|
|
|
1144
1204
|
const options = parseOptionsFromUrl(
|
|
1145
1205
|
reqUrl,
|
|
1146
1206
|
new Set(this._config.resolver.platforms),
|
|
1147
|
-
|
|
1207
|
+
getBytecodeVersion(),
|
|
1148
1208
|
);
|
|
1149
1209
|
|
|
1150
1210
|
const {
|
|
1151
1211
|
entryFile,
|
|
1152
|
-
transformOptions,
|
|
1153
|
-
serializerOptions,
|
|
1154
1212
|
graphOptions,
|
|
1155
1213
|
onProgress,
|
|
1214
|
+
resolverOptions,
|
|
1215
|
+
serializerOptions,
|
|
1216
|
+
transformOptions,
|
|
1156
1217
|
} = splitBundleOptions(options);
|
|
1157
1218
|
|
|
1158
1219
|
/**
|
|
@@ -1160,16 +1221,18 @@ class Server {
|
|
|
1160
1221
|
* to find the appropriate file with supported extensions.
|
|
1161
1222
|
*/
|
|
1162
1223
|
const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
|
|
1163
|
-
transformOptions,
|
|
1164
1224
|
relativeTo: 'server',
|
|
1225
|
+
resolverOptions,
|
|
1226
|
+
transformOptions,
|
|
1165
1227
|
});
|
|
1166
1228
|
|
|
1167
1229
|
const graphId = getGraphId(resolvedEntryFilePath, transformOptions, {
|
|
1168
|
-
shallow: graphOptions.shallow,
|
|
1169
1230
|
experimentalImportBundleSupport:
|
|
1170
1231
|
this._config.transformer.experimentalImportBundleSupport,
|
|
1171
1232
|
unstable_allowRequireContext:
|
|
1172
1233
|
this._config.transformer.unstable_allowRequireContext,
|
|
1234
|
+
resolverOptions,
|
|
1235
|
+
shallow: graphOptions.shallow,
|
|
1173
1236
|
});
|
|
1174
1237
|
let revision;
|
|
1175
1238
|
const revPromise = this._bundler.getRevisionByGraphId(graphId);
|
|
@@ -1177,6 +1240,7 @@ class Server {
|
|
|
1177
1240
|
({revision} = await this._bundler.initializeGraph(
|
|
1178
1241
|
resolvedEntryFilePath,
|
|
1179
1242
|
transformOptions,
|
|
1243
|
+
resolverOptions,
|
|
1180
1244
|
{onProgress, shallow: graphOptions.shallow},
|
|
1181
1245
|
));
|
|
1182
1246
|
} else {
|
|
@@ -1199,16 +1263,19 @@ class Server {
|
|
|
1199
1263
|
async _resolveRelativePath(
|
|
1200
1264
|
filePath: string,
|
|
1201
1265
|
{
|
|
1202
|
-
transformOptions,
|
|
1203
1266
|
relativeTo,
|
|
1267
|
+
resolverOptions,
|
|
1268
|
+
transformOptions,
|
|
1204
1269
|
}: $ReadOnly<{
|
|
1205
|
-
transformOptions: TransformInputOptions,
|
|
1206
1270
|
relativeTo: 'project' | 'server',
|
|
1271
|
+
resolverOptions: ResolverInputOptions,
|
|
1272
|
+
transformOptions: TransformInputOptions,
|
|
1207
1273
|
}>,
|
|
1208
1274
|
): Promise<string> {
|
|
1209
1275
|
const resolutionFn = await transformHelpers.getResolveDependencyFn(
|
|
1210
1276
|
this._bundler.getBundler(),
|
|
1211
1277
|
transformOptions.platform,
|
|
1278
|
+
resolverOptions,
|
|
1212
1279
|
);
|
|
1213
1280
|
const rootDir =
|
|
1214
1281
|
relativeTo === 'server'
|
|
@@ -1229,14 +1296,16 @@ class Server {
|
|
|
1229
1296
|
return this._config.watchFolders;
|
|
1230
1297
|
}
|
|
1231
1298
|
|
|
1232
|
-
static DEFAULT_GRAPH_OPTIONS: {
|
|
1233
|
-
|
|
1299
|
+
static DEFAULT_GRAPH_OPTIONS: $ReadOnly<{
|
|
1300
|
+
customResolverOptions: CustomResolverOptions,
|
|
1301
|
+
customTransformOptions: CustomTransformOptions,
|
|
1234
1302
|
dev: boolean,
|
|
1235
1303
|
hot: boolean,
|
|
1236
1304
|
minify: boolean,
|
|
1237
1305
|
runtimeBytecodeVersion: ?number,
|
|
1238
1306
|
unstable_transformProfile: 'default',
|
|
1239
|
-
} = {
|
|
1307
|
+
}> = {
|
|
1308
|
+
customResolverOptions: Object.create(null),
|
|
1240
1309
|
customTransformOptions: Object.create(null),
|
|
1241
1310
|
dev: true,
|
|
1242
1311
|
hot: false,
|
package/src/index.flow.js
CHANGED
|
@@ -340,14 +340,22 @@ exports.buildGraph = async function (
|
|
|
340
340
|
const bundler = new IncrementalBundler(mergedConfig);
|
|
341
341
|
|
|
342
342
|
try {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
343
|
+
const { customResolverOptions, ...defaultTransformInputOptions } =
|
|
344
|
+
MetroServer.DEFAULT_GRAPH_OPTIONS;
|
|
345
|
+
return await bundler.buildGraphForEntries(
|
|
346
|
+
entries,
|
|
347
|
+
{
|
|
348
|
+
...defaultTransformInputOptions,
|
|
349
|
+
customTransformOptions,
|
|
350
|
+
dev,
|
|
351
|
+
minify,
|
|
352
|
+
platform,
|
|
353
|
+
type,
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
customResolverOptions,
|
|
357
|
+
}
|
|
358
|
+
);
|
|
351
359
|
} finally {
|
|
352
360
|
bundler.end();
|
|
353
361
|
}
|
package/src/index.flow.js.flow
CHANGED
|
@@ -424,14 +424,20 @@ exports.buildGraph = async function (
|
|
|
424
424
|
const bundler = new IncrementalBundler(mergedConfig);
|
|
425
425
|
|
|
426
426
|
try {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
427
|
+
const {customResolverOptions, ...defaultTransformInputOptions} =
|
|
428
|
+
MetroServer.DEFAULT_GRAPH_OPTIONS;
|
|
429
|
+
return await bundler.buildGraphForEntries(
|
|
430
|
+
entries,
|
|
431
|
+
{
|
|
432
|
+
...defaultTransformInputOptions,
|
|
433
|
+
customTransformOptions,
|
|
434
|
+
dev,
|
|
435
|
+
minify,
|
|
436
|
+
platform,
|
|
437
|
+
type,
|
|
438
|
+
},
|
|
439
|
+
{customResolverOptions},
|
|
440
|
+
);
|
|
435
441
|
} finally {
|
|
436
442
|
bundler.end();
|
|
437
443
|
}
|
package/src/index.js
CHANGED
package/src/index.js.flow
CHANGED
package/src/lib/CountingSet.js
CHANGED
|
@@ -144,28 +144,21 @@ class TerminalReporter {
|
|
|
144
144
|
|
|
145
145
|
_logInitializing(port, hasReducedPerformance) {
|
|
146
146
|
const logo = [
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
" ###### ############# ####### ",
|
|
163
|
-
" ######### #### ######### ",
|
|
164
|
-
" ######### ######### ",
|
|
165
|
-
" ######### ######### ",
|
|
166
|
-
" ######### ",
|
|
167
|
-
" ",
|
|
168
|
-
" ",
|
|
147
|
+
"",
|
|
148
|
+
" ▒▒▓▓▓▓▒▒",
|
|
149
|
+
" ▒▓▓▓▒▒░░▒▒▓▓▓▒",
|
|
150
|
+
" ▒▓▓▓▓░░░▒▒▒▒░░░▓▓▓▓▒",
|
|
151
|
+
" ▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓",
|
|
152
|
+
" ▓▓░░░░░▒▓▓▓▓▓▓▒░░░░░▓▓",
|
|
153
|
+
" ▓▓░░▓▓▒░░░▒▒░░░▒▓▒░░▓▓",
|
|
154
|
+
" ▓▓░░▓▓▓▓▓▒▒▒▒▓▓▓▓▒░░▓▓",
|
|
155
|
+
" ▓▓░░▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░▓▓",
|
|
156
|
+
" ▓▓▒░░▒▒▓▓▓▓▓▓▓▓▒░░░▒▓▓",
|
|
157
|
+
" ▒▓▓▓▒░░░▒▓▓▒░░░▒▓▓▓▒",
|
|
158
|
+
" ▒▓▓▓▒░░░░▒▓▓▓▒",
|
|
159
|
+
" ▒▒▓▓▓▓▒▒",
|
|
160
|
+
"",
|
|
161
|
+
"",
|
|
169
162
|
];
|
|
170
163
|
const color = hasReducedPerformance ? chalk.red : chalk.blue;
|
|
171
164
|
this.terminal.log(color(logo.join("\n")));
|
|
@@ -258,9 +251,14 @@ class TerminalReporter {
|
|
|
258
251
|
|
|
259
252
|
case "dep_graph_loading":
|
|
260
253
|
const color = event.hasReducedPerformance ? chalk.red : chalk.blue;
|
|
254
|
+
|
|
255
|
+
const version = "v" + require("../../package.json").version;
|
|
256
|
+
|
|
261
257
|
this.terminal.log(
|
|
262
|
-
color.bold(
|
|
263
|
-
|
|
258
|
+
color.bold(
|
|
259
|
+
" ".repeat(19 - version.length / 2),
|
|
260
|
+
"Welcome to Metro " + chalk.white(version) + "\n"
|
|
261
|
+
) + chalk.dim(" Fast - Scalable - Integrated\n\n")
|
|
264
262
|
);
|
|
265
263
|
|
|
266
264
|
if (event.hasReducedPerformance) {
|