@@ -4,38 +4,14 @@ import path from "node:path";
4
4
import { Readable } from "node:stream" ;
5
5
import glob from "glob" ;
6
6
7
- async function cleanupManifest ( filename ) {
8
- let changed = false ;
9
-
10
- const manifestFile = path . resolve ( fileURLToPath ( import . meta. url ) , ".." , ".." , "dll" , filename ) ;
11
- const manifest = JSON . parse ( await fs . readFile ( manifestFile , { encoding : "utf8" } ) ) ;
12
-
13
- const polyfills = [
14
- "./node_modules/regenerator-runtime/" ,
15
- "./node_modules/@babel/runtime" ,
16
- "./node_modules/core-js" ,
17
- "tslib/tslib.es6.js" ,
18
- ] ;
19
-
20
- for ( const key in manifest . content ) {
21
- if ( polyfills . includes ( key ) ) {
22
- changed = true ;
23
- delete manifest . content [ key ] ;
24
- }
25
- }
26
- if ( changed ) {
27
- await fs . writeFile ( manifestFile , JSON . stringify ( manifest , null , 2 ) ) ;
28
- }
29
- }
30
-
31
- async function checkManifests ( pattern ) {
7
+ async function verifyManifests ( workspace ) {
32
8
const fileStream = new Readable ( { objectMode : true } ) ;
33
9
fileStream . _read = ( ) => { } ;
34
10
35
11
glob (
36
- pattern ,
12
+ workspace + "*-manifest.json" ,
37
13
{
38
- cwd : path . resolve ( fileURLToPath ( import . meta. url ) , ".." , ".." , "dll" ) ,
14
+ cwd : path . resolve ( fileURLToPath ( import . meta. url ) , ".." , ".." , workspace , "dll" ) ,
39
15
ignore : [ ] ,
40
16
} ,
41
17
( error , files ) => {
@@ -50,21 +26,50 @@ async function checkManifests(pattern) {
50
26
} ,
51
27
) ;
52
28
29
+ const polyfills = [
30
+ "./node_modules/regenerator-runtime/" ,
31
+ "./node_modules/@babel/runtime" ,
32
+ "./node_modules/core-js" ,
33
+ "./node_modules/tslib" ,
34
+ ] ;
35
+
53
36
for await ( const filePath of fileStream ) {
54
- const manifestFile = path . resolve ( fileURLToPath ( import . meta. url ) , ".." , ".." , "dll" , filePath ) ;
37
+ const manifestFile = path . resolve ( fileURLToPath ( import . meta. url ) , ".." , ".." , workspace , "dll" , filePath ) ;
55
38
const manifest = JSON . parse ( await fs . readFile ( manifestFile , { encoding : "utf8" } ) ) ;
56
39
57
40
for ( const entry in manifest . content ) {
58
41
if ( entry . startsWith ( "dll-reference" ) ) {
59
42
continue ;
60
43
}
44
+
61
45
if ( ! entry . startsWith ( "./node_modules" ) ) {
62
- throw new AssertionError ( `${ filename } contains wrongly linked reference ${ entry } ` ) ;
46
+ throw new AssertionError ( `${ filePath } contains wrongly linked reference ${ entry } ` ) ;
63
47
}
64
48
}
49
+
50
+ if ( ! filePath . startsWith ( workspace + "-" ) ) {
51
+ continue ;
52
+ }
53
+
54
+ let changed = false ;
55
+
56
+ for ( const entry in manifest . content ) {
57
+ if ( entry . startsWith ( "dll-reference" ) ) {
58
+ continue ;
59
+ }
60
+
61
+ if ( polyfills . some ( ( item ) => entry . indexOf ( item ) !== - 1 ) ) {
62
+ changed = true ;
63
+ delete manifest . content [ entry ] ;
64
+ }
65
+ }
66
+
67
+ if ( changed ) {
68
+ await fs . writeFile ( manifestFile , JSON . stringify ( manifest , null , 2 ) ) ;
69
+ }
65
70
}
66
71
}
67
72
68
- await cleanupManifest ( "bootstrap-prod-manifest.json ") ;
69
-
70
- await checkManifests ( "bootstrap*-manifest.json " ) ;
73
+ await verifyManifests ( "dependencies ") ;
74
+ await verifyManifests ( "platform" ) ;
75
+ await verifyManifests ( "bootstrap" ) ;
0 commit comments