@@ -20,10 +20,14 @@ export async function removeDistFolder(config: Config) {
20
20
* AOT and Closure compatible JavaScript
21
21
*/
22
22
export async function compilePackagesWithNgc ( config : Config ) {
23
- const [ storePkg , ...restPkgs ] = config . packages ;
23
+ const pkgs = util . getTopLevelPackages ( config ) ;
24
+ const storePkg = 'store' ;
25
+ const restPkgs = pkgs . filter ( name => name !== storePkg ) ;
26
+ const testPkgs = util . getTestingPackages ( config ) ;
24
27
25
28
await _compilePackagesWithNgc ( storePkg ) ;
26
29
await mapPackages ( restPkgs , _compilePackagesWithNgc ) ;
30
+ await mapPackages ( testPkgs , _compilePackagesWithNgc ) ;
27
31
}
28
32
29
33
async function _compilePackagesWithNgc ( pkg : string ) {
@@ -43,15 +47,19 @@ async function _compilePackagesWithNgc(pkg: string) {
43
47
* Uses Rollup to bundle the JavaScript into a single flat file called
44
48
* a FESM (Flat Ecma Script Module)
45
49
*/
46
- export async function bundleFesms ( { packages, scope} : Config ) {
47
- await mapPackages ( packages , async ( pkg ) => {
50
+ export async function bundleFesms ( config : Config ) {
51
+ const pkgs = util . getAllPackages ( config ) ;
52
+
53
+ await mapPackages ( pkgs , async ( pkg ) => {
54
+ const topLevelName = util . getTopLevelName ( pkg ) ;
55
+
48
56
await util . exec ( 'rollup' , [
49
57
`-i ./dist/packages/${ pkg } /index.js` ,
50
- `-o ./dist/${ pkg } /${ scope } /${ pkg } .js` ,
58
+ `-o ./dist/${ topLevelName } /${ config . scope } /${ pkg } .js` ,
51
59
`--sourcemap` ,
52
60
] ) ;
53
61
54
- await util . mapSources ( `./dist/${ pkg } /${ scope } /${ pkg } .js` ) ;
62
+ await util . mapSources ( `./dist/${ topLevelName } /${ config . scope } /${ pkg } .js` ) ;
55
63
} ) ;
56
64
}
57
65
@@ -60,7 +68,8 @@ export async function bundleFesms({packages, scope}: Config) {
60
68
* Copies each FESM into a TS file then uses TypeScript to downlevel
61
69
* the FESM into ES5 with ESM modules
62
70
*/
63
- export async function downLevelFesmsToES5 ( { packages, scope} : Config ) {
71
+ export async function downLevelFesmsToES5 ( config : Config ) {
72
+ const packages = util . getAllPackages ( config ) ;
64
73
const tscArgs = [
65
74
'--target es5' ,
66
75
'--module es2015' ,
@@ -69,31 +78,37 @@ export async function downLevelFesmsToES5({packages, scope}: Config) {
69
78
] ;
70
79
71
80
await mapPackages ( packages , async ( pkg ) => {
72
- const file = `./dist/${ pkg } /${ scope } /${ pkg } .js` ;
73
- const target = `./dist/${ pkg } /${ scope } /${ pkg } .es5.ts` ;
81
+ const topLevelName = util . getTopLevelName ( pkg ) ;
82
+
83
+ const file = `./dist/${ topLevelName } /${ config . scope } /${ pkg } .js` ;
84
+ const target = `./dist/${ topLevelName } /${ config . scope } /${ pkg } .es5.ts` ;
74
85
75
86
util . copy ( file , target ) ;
76
87
77
88
await util . ignoreErrors ( util . exec ( 'tsc' , [ target , ...tscArgs ] ) ) ;
78
89
await util . mapSources ( target . replace ( '.ts' , '.js' ) ) ;
90
+ await util . remove ( target ) ;
79
91
} ) ;
80
92
81
- await util . removeRecursively ( `./dist/?( ${ packages . join ( '|' ) } )/ ${ scope } /*.ts` ) ;
93
+ await util . removeRecursively ( `./dist/**/*/ ${ config . scope } /*.ts` ) ;
82
94
}
83
95
84
96
85
97
/**
86
98
* Re-runs Rollup on the downleveled ES5 to produce a UMD bundle
87
99
*/
88
- export async function createUmdBundles ( { packages} : Config ) {
89
- await mapPackages ( packages , async ( pkg ) => {
100
+ export async function createUmdBundles ( config : Config ) {
101
+ await mapPackages ( util . getAllPackages ( config ) , async ( pkg ) => {
102
+ const topLevelName = util . getTopLevelName ( pkg ) ;
103
+ const destinationName = util . getDestinationName ( pkg ) ;
104
+
90
105
const rollupArgs = [
91
106
`-c ./modules/${ pkg } /rollup.config.js` ,
92
107
`--sourcemap` ,
93
108
] ;
94
109
95
110
await util . exec ( 'rollup' , rollupArgs ) ;
96
- await util . mapSources ( `./dist/${ pkg } /bundles/${ pkg } .umd.js` ) ;
111
+ await util . mapSources ( `./dist/${ topLevelName } /bundles/${ destinationName } .umd.js` ) ;
97
112
} ) ;
98
113
}
99
114
@@ -103,7 +118,7 @@ export async function createUmdBundles({packages}: Config) {
103
118
* leaving any type definition files in place
104
119
*/
105
120
export async function cleanTypeScriptFiles ( config : Config ) {
106
- const tsFilesGlob = './dist/packages/**/*.js ' ;
121
+ const tsFilesGlob = './dist/packages/**/*.ts ' ;
107
122
const dtsFilesFlob = './dist/packages/**/*.d.ts' ;
108
123
const filesToRemove = await util . getListOfFiles ( tsFilesGlob , dtsFilesFlob ) ;
109
124
@@ -117,12 +132,14 @@ export async function cleanTypeScriptFiles(config: Config) {
117
132
* Renames the index files in each package to the name
118
133
* of the package.
119
134
*/
120
- export async function renamePackageEntryFiles ( { packages} : Config ) {
121
- await mapPackages ( packages , async ( pkg ) => {
135
+ export async function renamePackageEntryFiles ( config : Config ) {
136
+ await mapPackages ( util . getAllPackages ( config ) , async ( pkg ) => {
137
+ const bottomLevelName = util . getBottomLevelName ( pkg ) ;
138
+
122
139
const files = await util . getListOfFiles ( `./dist/packages/${ pkg } /index.**` ) ;
123
140
124
141
for ( let file of files ) {
125
- const target = file . replace ( 'index' , pkg ) ;
142
+ const target = file . replace ( 'index' , bottomLevelName ) ;
126
143
util . copy ( file , target ) ;
127
144
util . remove ( file ) ;
128
145
}
@@ -133,7 +150,9 @@ export async function renamePackageEntryFiles({packages}: Config) {
133
150
/**
134
151
* Removes any remaining source map files from running NGC
135
152
*/
136
- export async function removeRemainingSourceMapFiles ( { packages} : Config ) {
153
+ export async function removeRemainingSourceMapFiles ( config : Config ) {
154
+ const packages = util . getTopLevelPackages ( config ) ;
155
+
137
156
await util . removeRecursively ( `./dist/packages/?(${ packages . join ( '|' ) } )/**/*.map` ) ;
138
157
}
139
158
@@ -142,7 +161,8 @@ export async function removeRemainingSourceMapFiles({packages}: Config) {
142
161
* Copies the type definition files and NGC metadata files to
143
162
* the root of the distribution
144
163
*/
145
- export async function copyTypeDefinitionFiles ( { packages} : Config ) {
164
+ export async function copyTypeDefinitionFiles ( config : Config ) {
165
+ const packages = util . getTopLevelPackages ( config ) ;
146
166
const files = await util . getListOfFiles ( `./dist/packages/?(${ packages . join ( '|' ) } )/**/*` ) ;
147
167
148
168
for ( let file of files ) {
@@ -157,17 +177,19 @@ export async function copyTypeDefinitionFiles({packages}: Config) {
157
177
/**
158
178
* Creates minified copies of each UMD bundle
159
179
*/
160
- export async function minifyUmdBundles ( { packages } : Config ) {
180
+ export async function minifyUmdBundles ( config : Config ) {
161
181
const uglifyArgs = [
162
182
'-c' ,
163
183
'-m' ,
164
184
'--screw-ie8' ,
165
185
'--comments' ,
166
186
] ;
167
187
168
- await mapPackages ( packages , async ( pkg ) => {
169
- const file = `./dist/${ pkg } /bundles/${ pkg } .umd.js` ;
170
- const out = `./dist/${ pkg } /bundles/${ pkg } .umd.min.js` ;
188
+ await mapPackages ( util . getAllPackages ( config ) , async ( pkg ) => {
189
+ const topLevelName = util . getTopLevelName ( pkg ) ;
190
+ const destinationName = util . getDestinationName ( pkg ) ;
191
+ const file = `./dist/${ topLevelName } /bundles/${ destinationName } .umd.js` ;
192
+ const out = `./dist/${ topLevelName } /bundles/${ destinationName } .umd.min.js` ;
171
193
172
194
return util . exec ( 'uglifyjs' , [
173
195
...uglifyArgs ,
@@ -184,17 +206,29 @@ export async function minifyUmdBundles({packages}: Config) {
184
206
* Copies the README.md, LICENSE, and package.json files into
185
207
* each package
186
208
*/
187
- export async function copyPackageDocs ( { packages} : Config ) {
209
+ export async function copyDocs ( config : Config ) {
210
+ const packages = util . getTopLevelPackages ( config ) ;
211
+
188
212
for ( let pkg of packages ) {
189
213
const source = `./modules/${ pkg } ` ;
190
214
const target = `./dist/${ pkg } ` ;
191
215
192
- util . copy ( `${ source } /package.json` , `${ target } /package.json` ) ;
193
216
util . copy ( `${ source } /README.md` , `${ target } /README.md` ) ;
194
217
util . copy ( './LICENSE' , `${ target } /LICENSE` ) ;
195
218
}
196
219
}
197
220
221
+ export async function copyPackageJsonFiles ( config : Config ) {
222
+ const packages = util . getAllPackages ( config ) ;
223
+
224
+ for ( let pkg of packages ) {
225
+ const source = `./modules/${ pkg } ` ;
226
+ const target = `./dist/${ pkg } ` ;
227
+
228
+ util . copy ( `${ source } /package.json` , `${ target } /package.json` ) ;
229
+ }
230
+ }
231
+
198
232
199
233
/**
200
234
* Removes the packages folder
@@ -208,7 +242,7 @@ export async function removePackagesFolder(config: Config) {
208
242
* Deploy build artifacts to repos
209
243
*/
210
244
export async function publishToRepo ( config : Config ) {
211
- for ( let pkg of config . packages ) {
245
+ for ( let pkg of util . getTopLevelPackages ( config ) ) {
212
246
const SOURCE_DIR = `./dist/${ pkg } ` ;
213
247
const REPO_URL = `git@github.com:ngrx/${ pkg } -builds.git` ;
214
248
const REPO_DIR = `./tmp/${ pkg } ` ;
0 commit comments