@rnx-kit/cli 0.15.1 → 0.15.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/CHANGELOG.md +15 -0
- package/coverage/clover.xml +23 -115
- package/coverage/coverage-final.json +1 -2
- package/coverage/lcov-report/index.html +20 -35
- package/coverage/lcov-report/src/bundle/defaultPlugins.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/index.html +1 -1
- package/coverage/lcov-report/src/bundle/kit-config.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/metro.ts.html +1 -1
- package/coverage/lcov-report/src/bundle/overrides.ts.html +1 -1
- package/coverage/lcov-report/src/copy-assets.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +20 -20
- package/coverage/lcov-report/src/metro-config.ts.html +14 -323
- package/coverage/lcov.info +36 -207
- package/lib/metro-config.d.ts.map +1 -1
- package/lib/metro-config.js +2 -78
- package/lib/metro-config.js.map +1 -1
- package/package.json +5 -7
- package/src/metro-config.ts +3 -106
- package/coverage/lcov-report/src/typescript/index.html +0 -116
- package/coverage/lcov-report/src/typescript/project-cache.ts.html +0 -700
- package/lib/typescript/project-cache.d.ts +0 -42
- package/lib/typescript/project-cache.d.ts.map +0 -1
- package/lib/typescript/project-cache.js +0 -155
- package/lib/typescript/project-cache.js.map +0 -1
- package/src/typescript/project-cache.ts +0 -205
package/coverage/lcov.info
CHANGED
|
@@ -290,121 +290,44 @@ BRH:45
|
|
|
290
290
|
end_of_record
|
|
291
291
|
TN:
|
|
292
292
|
SF:src/metro-config.ts
|
|
293
|
-
FN:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
FN:53,(anonymous_3)
|
|
297
|
-
FN:58,(anonymous_4)
|
|
298
|
-
FN:68,(anonymous_5)
|
|
299
|
-
FN:79,(anonymous_6)
|
|
300
|
-
FN:91,(anonymous_7)
|
|
301
|
-
FN:107,(anonymous_8)
|
|
302
|
-
FN:118,customizeMetroConfig
|
|
303
|
-
FNF:10
|
|
304
|
-
FNH:2
|
|
305
|
-
FNDA:9,createSerializerHook
|
|
306
|
-
FNDA:0,(anonymous_1)
|
|
307
|
-
FNDA:0,(anonymous_2)
|
|
308
|
-
FNDA:0,(anonymous_3)
|
|
309
|
-
FNDA:0,(anonymous_4)
|
|
310
|
-
FNDA:0,(anonymous_5)
|
|
311
|
-
FNDA:0,(anonymous_6)
|
|
312
|
-
FNDA:0,(anonymous_7)
|
|
313
|
-
FNDA:0,(anonymous_8)
|
|
293
|
+
FN:20,customizeMetroConfig
|
|
294
|
+
FNF:1
|
|
295
|
+
FNH:1
|
|
314
296
|
FNDA:10,customizeMetroConfig
|
|
315
|
-
DA:
|
|
316
|
-
DA:
|
|
297
|
+
DA:32,10
|
|
298
|
+
DA:34,10
|
|
299
|
+
DA:35,10
|
|
300
|
+
DA:36,1
|
|
317
301
|
DA:37,9
|
|
318
|
-
DA:
|
|
319
|
-
DA:40,
|
|
320
|
-
DA:41,
|
|
321
|
-
DA:42,
|
|
322
|
-
DA:
|
|
323
|
-
DA:
|
|
324
|
-
DA:
|
|
325
|
-
DA:
|
|
326
|
-
DA:
|
|
327
|
-
DA:
|
|
328
|
-
DA:
|
|
329
|
-
DA:
|
|
330
|
-
DA:
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
DA:99,0
|
|
348
|
-
DA:104,9
|
|
349
|
-
DA:107,2
|
|
350
|
-
DA:130,10
|
|
351
|
-
DA:132,10
|
|
352
|
-
DA:133,10
|
|
353
|
-
DA:134,1
|
|
354
|
-
DA:135,9
|
|
355
|
-
DA:136,5
|
|
356
|
-
DA:138,10
|
|
357
|
-
DA:139,1
|
|
358
|
-
DA:140,9
|
|
359
|
-
DA:141,5
|
|
360
|
-
DA:144,10
|
|
361
|
-
DA:145,4
|
|
362
|
-
DA:146,4
|
|
363
|
-
DA:147,6
|
|
364
|
-
DA:158,4
|
|
365
|
-
DA:162,2
|
|
366
|
-
DA:165,10
|
|
367
|
-
DA:166,10
|
|
368
|
-
DA:167,0
|
|
369
|
-
DA:168,10
|
|
370
|
-
DA:169,9
|
|
371
|
-
DA:171,10
|
|
372
|
-
LF:57
|
|
373
|
-
LH:27
|
|
374
|
-
BRDA:41,0,0,0
|
|
375
|
-
BRDA:41,0,1,0
|
|
376
|
-
BRDA:42,1,0,0
|
|
377
|
-
BRDA:42,1,1,0
|
|
378
|
-
BRDA:70,2,0,0
|
|
379
|
-
BRDA:70,2,1,0
|
|
380
|
-
BRDA:73,3,0,0
|
|
381
|
-
BRDA:73,3,1,0
|
|
382
|
-
BRDA:81,4,0,0
|
|
383
|
-
BRDA:81,4,1,0
|
|
384
|
-
BRDA:92,5,0,0
|
|
385
|
-
BRDA:92,5,1,0
|
|
386
|
-
BRDA:97,6,0,0
|
|
387
|
-
BRDA:97,6,1,0
|
|
388
|
-
BRDA:97,7,0,0
|
|
389
|
-
BRDA:97,7,1,0
|
|
390
|
-
BRDA:133,8,0,1
|
|
391
|
-
BRDA:133,8,1,9
|
|
392
|
-
BRDA:135,9,0,5
|
|
393
|
-
BRDA:135,9,1,4
|
|
394
|
-
BRDA:138,10,0,1
|
|
395
|
-
BRDA:138,10,1,9
|
|
396
|
-
BRDA:140,11,0,5
|
|
397
|
-
BRDA:140,11,1,4
|
|
398
|
-
BRDA:144,12,0,4
|
|
399
|
-
BRDA:144,12,1,6
|
|
400
|
-
BRDA:147,13,0,4
|
|
401
|
-
BRDA:147,13,1,2
|
|
402
|
-
BRDA:166,14,0,0
|
|
403
|
-
BRDA:166,14,1,10
|
|
404
|
-
BRDA:168,15,0,9
|
|
405
|
-
BRDA:168,15,1,1
|
|
406
|
-
BRF:32
|
|
407
|
-
BRH:15
|
|
302
|
+
DA:38,5
|
|
303
|
+
DA:40,10
|
|
304
|
+
DA:41,1
|
|
305
|
+
DA:42,9
|
|
306
|
+
DA:43,5
|
|
307
|
+
DA:46,10
|
|
308
|
+
DA:47,4
|
|
309
|
+
DA:48,4
|
|
310
|
+
DA:49,6
|
|
311
|
+
DA:60,4
|
|
312
|
+
DA:64,2
|
|
313
|
+
DA:67,10
|
|
314
|
+
DA:68,10
|
|
315
|
+
LF:18
|
|
316
|
+
LH:18
|
|
317
|
+
BRDA:35,0,0,1
|
|
318
|
+
BRDA:35,0,1,9
|
|
319
|
+
BRDA:37,1,0,5
|
|
320
|
+
BRDA:37,1,1,4
|
|
321
|
+
BRDA:40,2,0,1
|
|
322
|
+
BRDA:40,2,1,9
|
|
323
|
+
BRDA:42,3,0,5
|
|
324
|
+
BRDA:42,3,1,4
|
|
325
|
+
BRDA:46,4,0,4
|
|
326
|
+
BRDA:46,4,1,6
|
|
327
|
+
BRDA:49,5,0,4
|
|
328
|
+
BRDA:49,5,1,2
|
|
329
|
+
BRF:12
|
|
330
|
+
BRH:12
|
|
408
331
|
end_of_record
|
|
409
332
|
TN:
|
|
410
333
|
SF:src/bundle/defaultPlugins.ts
|
|
@@ -504,97 +427,3 @@ BRDA:45,0,1,1
|
|
|
504
427
|
BRF:2
|
|
505
428
|
BRH:2
|
|
506
429
|
end_of_record
|
|
507
|
-
TN:
|
|
508
|
-
SF:src/typescript/project-cache.ts
|
|
509
|
-
FN:60,createProjectCache
|
|
510
|
-
FN:72,findProjectRoot
|
|
511
|
-
FN:91,readTSConfig
|
|
512
|
-
FN:110,(anonymous_3)
|
|
513
|
-
FN:117,createProjectInfo
|
|
514
|
-
FN:138,(anonymous_5)
|
|
515
|
-
FN:142,(anonymous_6)
|
|
516
|
-
FN:166,getProjectInfo
|
|
517
|
-
FN:189,clearPlatform
|
|
518
|
-
FN:190,(anonymous_9)
|
|
519
|
-
FNF:10
|
|
520
|
-
FNH:1
|
|
521
|
-
FNDA:9,createProjectCache
|
|
522
|
-
FNDA:0,findProjectRoot
|
|
523
|
-
FNDA:0,readTSConfig
|
|
524
|
-
FNDA:0,(anonymous_3)
|
|
525
|
-
FNDA:0,createProjectInfo
|
|
526
|
-
FNDA:0,(anonymous_5)
|
|
527
|
-
FNDA:0,(anonymous_6)
|
|
528
|
-
FNDA:0,getProjectInfo
|
|
529
|
-
FNDA:0,clearPlatform
|
|
530
|
-
FNDA:0,(anonymous_9)
|
|
531
|
-
DA:63,9
|
|
532
|
-
DA:64,9
|
|
533
|
-
DA:70,9
|
|
534
|
-
DA:74,0
|
|
535
|
-
DA:75,0
|
|
536
|
-
DA:76,0
|
|
537
|
-
DA:81,0
|
|
538
|
-
DA:82,0
|
|
539
|
-
DA:83,0
|
|
540
|
-
DA:88,0
|
|
541
|
-
DA:92,0
|
|
542
|
-
DA:93,0
|
|
543
|
-
DA:102,0
|
|
544
|
-
DA:105,0
|
|
545
|
-
DA:106,0
|
|
546
|
-
DA:107,0
|
|
547
|
-
DA:108,0
|
|
548
|
-
DA:109,0
|
|
549
|
-
DA:110,0
|
|
550
|
-
DA:111,0
|
|
551
|
-
DA:114,0
|
|
552
|
-
DA:122,0
|
|
553
|
-
DA:123,0
|
|
554
|
-
DA:125,0
|
|
555
|
-
DA:137,0
|
|
556
|
-
DA:138,0
|
|
557
|
-
DA:142,0
|
|
558
|
-
DA:143,0
|
|
559
|
-
DA:144,0
|
|
560
|
-
DA:145,0
|
|
561
|
-
DA:153,0
|
|
562
|
-
DA:160,0
|
|
563
|
-
DA:170,0
|
|
564
|
-
DA:171,0
|
|
565
|
-
DA:173,0
|
|
566
|
-
DA:177,0
|
|
567
|
-
DA:178,0
|
|
568
|
-
DA:184,0
|
|
569
|
-
DA:185,0
|
|
570
|
-
DA:186,0
|
|
571
|
-
DA:190,0
|
|
572
|
-
DA:191,0
|
|
573
|
-
DA:192,0
|
|
574
|
-
DA:193,0
|
|
575
|
-
DA:194,0
|
|
576
|
-
DA:196,0
|
|
577
|
-
DA:201,9
|
|
578
|
-
LF:47
|
|
579
|
-
LH:4
|
|
580
|
-
BRDA:75,0,0,0
|
|
581
|
-
BRDA:75,0,1,0
|
|
582
|
-
BRDA:82,1,0,0
|
|
583
|
-
BRDA:82,1,1,0
|
|
584
|
-
BRDA:93,2,0,0
|
|
585
|
-
BRDA:93,2,1,0
|
|
586
|
-
BRDA:106,3,0,0
|
|
587
|
-
BRDA:106,3,1,0
|
|
588
|
-
BRDA:108,4,0,0
|
|
589
|
-
BRDA:108,4,1,0
|
|
590
|
-
BRDA:123,5,0,0
|
|
591
|
-
BRDA:123,5,1,0
|
|
592
|
-
BRDA:177,6,0,0
|
|
593
|
-
BRDA:177,6,1,0
|
|
594
|
-
BRDA:192,7,0,0
|
|
595
|
-
BRDA:192,7,1,0
|
|
596
|
-
BRDA:193,8,0,0
|
|
597
|
-
BRDA:193,8,1,0
|
|
598
|
-
BRF:18
|
|
599
|
-
BRH:0
|
|
600
|
-
end_of_record
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metro-config.d.ts","sourceRoot":"","sources":["../src/metro-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"metro-config.d.ts","sourceRoot":"","sources":["../src/metro-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAUtD,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,cAAc,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,mBAAmB,EAAE,YAAY,EACjC,EACE,wBAAwB,EACxB,2BAA2B,EAC3B,SAAS,EACT,oBAAoB,GACrB,EAAE,cAAc,EACjB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAChC,IAAI,CAwCN"}
|
package/lib/metro-config.js
CHANGED
|
@@ -3,79 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.customizeMetroConfig = void 0;
|
|
4
4
|
const metro_plugin_cyclic_dependencies_detector_1 = require("@rnx-kit/metro-plugin-cyclic-dependencies-detector");
|
|
5
5
|
const metro_plugin_duplicates_checker_1 = require("@rnx-kit/metro-plugin-duplicates-checker");
|
|
6
|
+
const metro_plugin_typescript_1 = require("@rnx-kit/metro-plugin-typescript");
|
|
6
7
|
const metro_serializer_1 = require("@rnx-kit/metro-serializer");
|
|
7
8
|
const metro_serializer_esbuild_1 = require("@rnx-kit/metro-serializer-esbuild");
|
|
8
|
-
const project_cache_1 = require("./typescript/project-cache");
|
|
9
|
-
/**
|
|
10
|
-
* Create a hook function to be registered with Metro during serialization.
|
|
11
|
-
* Each serialization pass runs the hook which type-checks each added/updated
|
|
12
|
-
* source file.
|
|
13
|
-
*
|
|
14
|
-
* Source file in node_modules (external packages) are ignored.
|
|
15
|
-
*
|
|
16
|
-
* @param options TypeScript validation options
|
|
17
|
-
* @param print Optional function to use when printing status messages to the Metro console
|
|
18
|
-
* @returns Hook function
|
|
19
|
-
*/
|
|
20
|
-
function createSerializerHook(options, print) {
|
|
21
|
-
const projectCache = (0, project_cache_1.createProjectCache)(print);
|
|
22
|
-
const patternNodeModules = /[/\\]node_modules[/\\]/;
|
|
23
|
-
const excludeNodeModules = (p) => !patternNodeModules.test(p);
|
|
24
|
-
const hook = (graph, delta) => {
|
|
25
|
-
const platform = graph.transformOptions.platform;
|
|
26
|
-
if (platform) {
|
|
27
|
-
if (delta.reset) {
|
|
28
|
-
// Metro is signaling that all cached data for this Graph should be
|
|
29
|
-
// thrown out. Each Graph is scoped to one platform, so discard all
|
|
30
|
-
// of that platform's projects.
|
|
31
|
-
projectCache.clearPlatform(platform);
|
|
32
|
-
}
|
|
33
|
-
// Filter adds, updates, and deletes coming from Metro. Do not look at
|
|
34
|
-
// anything in an external package (e.g. under node_modules).
|
|
35
|
-
const adds = Array.from(delta.added.values(), (module) => module.path).filter(excludeNodeModules);
|
|
36
|
-
const updates = Array.from(delta.modified.values(), (module) => module.path).filter(excludeNodeModules);
|
|
37
|
-
const deletes = Array.from(delta.deleted.values()).filter(excludeNodeModules);
|
|
38
|
-
// Try to map each file to a TypeScript project, and apply its delta operation.
|
|
39
|
-
// Some projects may not actually be TypeScript projects (ignore those).
|
|
40
|
-
const tsprojectsToValidate = new Set();
|
|
41
|
-
adds.concat(updates).forEach((sourceFile) => {
|
|
42
|
-
const projectInfo = projectCache.getProjectInfo(sourceFile, platform);
|
|
43
|
-
if (projectInfo) {
|
|
44
|
-
// This is a TypeScript project. Validate it.
|
|
45
|
-
const { tsproject, tssourceFiles } = projectInfo;
|
|
46
|
-
if (tssourceFiles.has(sourceFile)) {
|
|
47
|
-
tsproject.setFile(sourceFile);
|
|
48
|
-
tsprojectsToValidate.add(tsproject);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
deletes.forEach((sourceFile) => {
|
|
53
|
-
const projectInfo = projectCache.getProjectInfo(sourceFile, platform);
|
|
54
|
-
if (projectInfo) {
|
|
55
|
-
// This is a TypeScript project. Validate it.
|
|
56
|
-
const { tsproject } = projectInfo;
|
|
57
|
-
tsproject.removeFile(sourceFile);
|
|
58
|
-
tsprojectsToValidate.add(tsproject);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
// Validate all projects which changed, printing all type errors.
|
|
62
|
-
let isValid = true;
|
|
63
|
-
tsprojectsToValidate.forEach((p) => {
|
|
64
|
-
if (!p.validate()) {
|
|
65
|
-
isValid = false;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
if (!isValid && options.throwOnError) {
|
|
69
|
-
// Type-checking failed. Fail the Metro operation (bundling or serving).
|
|
70
|
-
throw new Error("Type validation failed");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return hook;
|
|
75
|
-
}
|
|
76
|
-
const emptySerializerHook = (_graph, _delta) => {
|
|
77
|
-
// nop
|
|
78
|
-
};
|
|
79
9
|
/**
|
|
80
10
|
* Customize the Metro configuration.
|
|
81
11
|
*
|
|
@@ -120,13 +50,7 @@ function customizeMetroConfig(metroConfigReadonly, { detectCyclicDependencies, d
|
|
|
120
50
|
else {
|
|
121
51
|
delete metroConfig.serializer.customSerializer;
|
|
122
52
|
}
|
|
123
|
-
|
|
124
|
-
if (typeof typescriptValidation === "object") {
|
|
125
|
-
hook = createSerializerHook(typescriptValidation, print);
|
|
126
|
-
}
|
|
127
|
-
else if (typescriptValidation !== false) {
|
|
128
|
-
hook = createSerializerHook({}, print);
|
|
129
|
-
}
|
|
53
|
+
const hook = (0, metro_plugin_typescript_1.TypeScriptPlugin)(typescriptValidation, print);
|
|
130
54
|
metroConfig.serializer.experimentalSerializerHook = hook;
|
|
131
55
|
}
|
|
132
56
|
exports.customizeMetroConfig = customizeMetroConfig;
|
package/lib/metro-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metro-config.js","sourceRoot":"","sources":["../src/metro-config.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"metro-config.js","sourceRoot":"","sources":["../src/metro-config.ts"],"names":[],"mappings":";;;AACA,kHAAwF;AACxF,8FAAiF;AACjF,8EAAoE;AAEpE,gEAA4D;AAC5D,gFAG2C;AAG3C;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,mBAAiC,EACjC,EACE,wBAAwB,EACxB,2BAA2B,EAC3B,SAAS,EACT,oBAAoB,GACL,EACjB,KAAiC;IAEjC,uEAAuE;IACvE,qEAAqE;IACrE,MAAM,WAAW,GAAG,mBAAmC,CAAC;IAExD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,IAAI,OAAO,2BAA2B,KAAK,QAAQ,EAAE;QACnD,OAAO,CAAC,IAAI,CAAC,IAAA,uDAAqB,EAAC,2BAA2B,CAAC,CAAC,CAAC;KAClE;SAAM,IAAI,2BAA2B,KAAK,KAAK,EAAE;QAChD,OAAO,CAAC,IAAI,CAAC,IAAA,uDAAqB,GAAE,CAAC,CAAC;KACvC;IACD,IAAI,OAAO,wBAAwB,KAAK,QAAQ,EAAE;QAChD,OAAO,CAAC,IAAI,CAAC,IAAA,8DAAkB,EAAC,wBAAwB,CAAC,CAAC,CAAC;KAC5D;SAAM,IAAI,wBAAwB,KAAK,KAAK,EAAE;QAC7C,OAAO,CAAC,IAAI,CAAC,IAAA,8DAAkB,GAAE,CAAC,CAAC;KACpC;IAED,IAAI,SAAS,EAAE;QACb,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,IAAA,0CAAsB,EAAC,OAAO,CAAC,CAAC;QAC1E,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,mDAAwB,CAAC,CAAC;KAClE;SAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,qEAAqE;QACrE,oEAAoE;QACpE,gDAAgD;QAChD,EAAE;QACF,kEAAkE;QAClE,sEAAsE;QACtE,mCAAmC;QACnC,EAAE;QACF,kEAAkE;QAClE,wCAAwC;QACxC,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,IAAA,kCAAe,EACvD,OAAO,CACiC,CAAC;KAC5C;SAAM;QACL,OAAO,WAAW,CAAC,UAAU,CAAC,gBAAgB,CAAC;KAChD;IAED,MAAM,IAAI,GAAG,IAAA,0CAAgB,EAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;IAC3D,WAAW,CAAC,UAAU,CAAC,0BAA0B,GAAG,IAAI,CAAC;AAC3D,CAAC;AAjDD,oDAiDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnx-kit/cli",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "Command-line interface for working with kit packages in your repo",
|
|
5
5
|
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/cli",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,15 +24,14 @@
|
|
|
24
24
|
"@rnx-kit/console": "^1.0.11",
|
|
25
25
|
"@rnx-kit/metro-plugin-cyclic-dependencies-detector": "^1.0.21",
|
|
26
26
|
"@rnx-kit/metro-plugin-duplicates-checker": "^2.0.0",
|
|
27
|
+
"@rnx-kit/metro-plugin-typescript": "^0.2.0",
|
|
27
28
|
"@rnx-kit/metro-serializer": "^1.0.11",
|
|
28
29
|
"@rnx-kit/metro-serializer-esbuild": "^0.1.0",
|
|
29
30
|
"@rnx-kit/metro-service": "^3.0.2",
|
|
30
31
|
"@rnx-kit/third-party-notices": "^1.2.13",
|
|
31
32
|
"@rnx-kit/tools-language": "^1.4.1",
|
|
32
|
-
"@rnx-kit/tools-node": "^1.
|
|
33
|
-
"@rnx-kit/tools-react-native": "^1.2.
|
|
34
|
-
"@rnx-kit/typescript-react-native-resolver": "^0.3.0",
|
|
35
|
-
"@rnx-kit/typescript-service": "^1.5.3",
|
|
33
|
+
"@rnx-kit/tools-node": "^1.3.1",
|
|
34
|
+
"@rnx-kit/tools-react-native": "^1.2.3",
|
|
36
35
|
"chalk": "^4.1.0",
|
|
37
36
|
"find-up": "^5.0.0",
|
|
38
37
|
"fs-extra": "^10.0.0",
|
|
@@ -62,8 +61,7 @@
|
|
|
62
61
|
"jest": "^27.0.0",
|
|
63
62
|
"jest-extended": "^2.0.0",
|
|
64
63
|
"memfs": "^3.4.1",
|
|
65
|
-
"metro-config": "^0.67.0"
|
|
66
|
-
"typescript": "^4.0.0"
|
|
64
|
+
"metro-config": "^0.67.0"
|
|
67
65
|
},
|
|
68
66
|
"depcheck": {
|
|
69
67
|
"ignoreMatches": [
|
package/src/metro-config.ts
CHANGED
|
@@ -1,112 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BundlerPlugins,
|
|
3
|
-
TypeScriptValidationOptions,
|
|
4
|
-
} from "@rnx-kit/config";
|
|
1
|
+
import type { BundlerPlugins } from "@rnx-kit/config";
|
|
5
2
|
import { CyclicDependencies } from "@rnx-kit/metro-plugin-cyclic-dependencies-detector";
|
|
6
3
|
import { DuplicateDependencies } from "@rnx-kit/metro-plugin-duplicates-checker";
|
|
4
|
+
import { TypeScriptPlugin } from "@rnx-kit/metro-plugin-typescript";
|
|
7
5
|
import type { MetroPlugin } from "@rnx-kit/metro-serializer";
|
|
8
6
|
import { MetroSerializer } from "@rnx-kit/metro-serializer";
|
|
9
7
|
import {
|
|
10
8
|
esbuildTransformerConfig,
|
|
11
9
|
MetroSerializer as MetroSerializerEsbuild,
|
|
12
10
|
} from "@rnx-kit/metro-serializer-esbuild";
|
|
13
|
-
import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform";
|
|
14
|
-
import type { Project } from "@rnx-kit/typescript-service";
|
|
15
|
-
import type { DeltaResult, Graph } from "metro";
|
|
16
11
|
import type { InputConfigT, SerializerConfigT } from "metro-config";
|
|
17
|
-
import { createProjectCache } from "./typescript/project-cache";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Create a hook function to be registered with Metro during serialization.
|
|
21
|
-
* Each serialization pass runs the hook which type-checks each added/updated
|
|
22
|
-
* source file.
|
|
23
|
-
*
|
|
24
|
-
* Source file in node_modules (external packages) are ignored.
|
|
25
|
-
*
|
|
26
|
-
* @param options TypeScript validation options
|
|
27
|
-
* @param print Optional function to use when printing status messages to the Metro console
|
|
28
|
-
* @returns Hook function
|
|
29
|
-
*/
|
|
30
|
-
function createSerializerHook(
|
|
31
|
-
options: TypeScriptValidationOptions,
|
|
32
|
-
print?: (message: string) => void
|
|
33
|
-
) {
|
|
34
|
-
const projectCache = createProjectCache(print);
|
|
35
|
-
|
|
36
|
-
const patternNodeModules = /[/\\]node_modules[/\\]/;
|
|
37
|
-
const excludeNodeModules = (p: string) => !patternNodeModules.test(p);
|
|
38
|
-
|
|
39
|
-
const hook = (graph: Graph, delta: DeltaResult): void => {
|
|
40
|
-
const platform = graph.transformOptions.platform as AllPlatforms;
|
|
41
|
-
if (platform) {
|
|
42
|
-
if (delta.reset) {
|
|
43
|
-
// Metro is signaling that all cached data for this Graph should be
|
|
44
|
-
// thrown out. Each Graph is scoped to one platform, so discard all
|
|
45
|
-
// of that platform's projects.
|
|
46
|
-
projectCache.clearPlatform(platform);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Filter adds, updates, and deletes coming from Metro. Do not look at
|
|
50
|
-
// anything in an external package (e.g. under node_modules).
|
|
51
|
-
const adds = Array.from(
|
|
52
|
-
delta.added.values(),
|
|
53
|
-
(module) => module.path
|
|
54
|
-
).filter(excludeNodeModules);
|
|
55
|
-
|
|
56
|
-
const updates = Array.from(
|
|
57
|
-
delta.modified.values(),
|
|
58
|
-
(module) => module.path
|
|
59
|
-
).filter(excludeNodeModules);
|
|
60
|
-
|
|
61
|
-
const deletes = Array.from(delta.deleted.values()).filter(
|
|
62
|
-
excludeNodeModules
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
// Try to map each file to a TypeScript project, and apply its delta operation.
|
|
66
|
-
// Some projects may not actually be TypeScript projects (ignore those).
|
|
67
|
-
const tsprojectsToValidate: Set<Project> = new Set();
|
|
68
|
-
adds.concat(updates).forEach((sourceFile) => {
|
|
69
|
-
const projectInfo = projectCache.getProjectInfo(sourceFile, platform);
|
|
70
|
-
if (projectInfo) {
|
|
71
|
-
// This is a TypeScript project. Validate it.
|
|
72
|
-
const { tsproject, tssourceFiles } = projectInfo;
|
|
73
|
-
if (tssourceFiles.has(sourceFile)) {
|
|
74
|
-
tsproject.setFile(sourceFile);
|
|
75
|
-
tsprojectsToValidate.add(tsproject);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
deletes.forEach((sourceFile) => {
|
|
80
|
-
const projectInfo = projectCache.getProjectInfo(sourceFile, platform);
|
|
81
|
-
if (projectInfo) {
|
|
82
|
-
// This is a TypeScript project. Validate it.
|
|
83
|
-
const { tsproject } = projectInfo;
|
|
84
|
-
tsproject.removeFile(sourceFile);
|
|
85
|
-
tsprojectsToValidate.add(tsproject);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Validate all projects which changed, printing all type errors.
|
|
90
|
-
let isValid = true;
|
|
91
|
-
tsprojectsToValidate.forEach((p) => {
|
|
92
|
-
if (!p.validate()) {
|
|
93
|
-
isValid = false;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
if (!isValid && options.throwOnError) {
|
|
98
|
-
// Type-checking failed. Fail the Metro operation (bundling or serving).
|
|
99
|
-
throw new Error("Type validation failed");
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
return hook;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const emptySerializerHook = (_graph: Graph, _delta: DeltaResult): void => {
|
|
108
|
-
// nop
|
|
109
|
-
};
|
|
110
12
|
|
|
111
13
|
/**
|
|
112
14
|
* Customize the Metro configuration.
|
|
@@ -162,11 +64,6 @@ export function customizeMetroConfig(
|
|
|
162
64
|
delete metroConfig.serializer.customSerializer;
|
|
163
65
|
}
|
|
164
66
|
|
|
165
|
-
|
|
166
|
-
if (typeof typescriptValidation === "object") {
|
|
167
|
-
hook = createSerializerHook(typescriptValidation, print);
|
|
168
|
-
} else if (typescriptValidation !== false) {
|
|
169
|
-
hook = createSerializerHook({}, print);
|
|
170
|
-
}
|
|
67
|
+
const hook = TypeScriptPlugin(typescriptValidation, print);
|
|
171
68
|
metroConfig.serializer.experimentalSerializerHook = hook;
|
|
172
69
|
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for src/typescript</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> src/typescript</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">8.16% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>4/49</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">0% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>0/18</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">10% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>1/10</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">8.51% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>4/47</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input oninput="onInput()" type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line low'></div>
|
|
65
|
-
<div class="pad1">
|
|
66
|
-
<table class="coverage-summary">
|
|
67
|
-
<thead>
|
|
68
|
-
<tr>
|
|
69
|
-
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
|
70
|
-
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
|
71
|
-
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
|
72
|
-
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
73
|
-
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
|
74
|
-
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
75
|
-
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
|
76
|
-
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
77
|
-
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
|
78
|
-
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
|
79
|
-
</tr>
|
|
80
|
-
</thead>
|
|
81
|
-
<tbody><tr>
|
|
82
|
-
<td class="file low" data-value="project-cache.ts"><a href="project-cache.ts.html">project-cache.ts</a></td>
|
|
83
|
-
<td data-value="8.16" class="pic low">
|
|
84
|
-
<div class="chart"><div class="cover-fill" style="width: 8%"></div><div class="cover-empty" style="width: 92%"></div></div>
|
|
85
|
-
</td>
|
|
86
|
-
<td data-value="8.16" class="pct low">8.16%</td>
|
|
87
|
-
<td data-value="49" class="abs low">4/49</td>
|
|
88
|
-
<td data-value="0" class="pct low">0%</td>
|
|
89
|
-
<td data-value="18" class="abs low">0/18</td>
|
|
90
|
-
<td data-value="10" class="pct low">10%</td>
|
|
91
|
-
<td data-value="10" class="abs low">1/10</td>
|
|
92
|
-
<td data-value="8.51" class="pct low">8.51%</td>
|
|
93
|
-
<td data-value="47" class="abs low">4/47</td>
|
|
94
|
-
</tr>
|
|
95
|
-
|
|
96
|
-
</tbody>
|
|
97
|
-
</table>
|
|
98
|
-
</div>
|
|
99
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
100
|
-
</div><!-- /wrapper -->
|
|
101
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
|
-
Code coverage generated by
|
|
103
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
-
at Mon Dec 05 2022 16:15:26 GMT+0000 (Coordinated Universal Time)
|
|
105
|
-
</div>
|
|
106
|
-
<script src="../../prettify.js"></script>
|
|
107
|
-
<script>
|
|
108
|
-
window.onload = function () {
|
|
109
|
-
prettyPrint();
|
|
110
|
-
};
|
|
111
|
-
</script>
|
|
112
|
-
<script src="../../sorter.js"></script>
|
|
113
|
-
<script src="../../block-navigation.js"></script>
|
|
114
|
-
</body>
|
|
115
|
-
</html>
|
|
116
|
-
|