@@ -20,10 +20,14 @@ export async function removeDistFolder(config: Config) {
2020 * AOT and Closure compatible JavaScript
2121 */
2222export 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 ) ;
2427
2528 await _compilePackagesWithNgc ( storePkg ) ;
2629 await mapPackages ( restPkgs , _compilePackagesWithNgc ) ;
30+ await mapPackages ( testPkgs , _compilePackagesWithNgc ) ;
2731}
2832
2933async function _compilePackagesWithNgc ( pkg : string ) {
@@ -43,15 +47,19 @@ async function _compilePackagesWithNgc(pkg: string) {
4347 * Uses Rollup to bundle the JavaScript into a single flat file called
4448 * a FESM (Flat Ecma Script Module)
4549 */
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+
4856 await util . exec ( 'rollup' , [
4957 `-i ./dist/packages/${ pkg } /index.js` ,
50- `-o ./dist/${ pkg } /${ scope } /${ pkg } .js` ,
58+ `-o ./dist/${ topLevelName } /${ config . scope } /${ pkg } .js` ,
5159 `--sourcemap` ,
5260 ] ) ;
5361
54- await util . mapSources ( `./dist/${ pkg } /${ scope } /${ pkg } .js` ) ;
62+ await util . mapSources ( `./dist/${ topLevelName } /${ config . scope } /${ pkg } .js` ) ;
5563 } ) ;
5664}
5765
@@ -60,7 +68,8 @@ export async function bundleFesms({packages, scope}: Config) {
6068 * Copies each FESM into a TS file then uses TypeScript to downlevel
6169 * the FESM into ES5 with ESM modules
6270 */
63- export async function downLevelFesmsToES5 ( { packages, scope} : Config ) {
71+ export async function downLevelFesmsToES5 ( config : Config ) {
72+ const packages = util . getAllPackages ( config ) ;
6473 const tscArgs = [
6574 '--target es5' ,
6675 '--module es2015' ,
@@ -69,31 +78,37 @@ export async function downLevelFesmsToES5({packages, scope}: Config) {
6978 ] ;
7079
7180 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` ;
7485
7586 util . copy ( file , target ) ;
7687
7788 await util . ignoreErrors ( util . exec ( 'tsc' , [ target , ...tscArgs ] ) ) ;
7889 await util . mapSources ( target . replace ( '.ts' , '.js' ) ) ;
90+ await util . remove ( target ) ;
7991 } ) ;
8092
81- await util . removeRecursively ( `./dist/?( ${ packages . join ( '|' ) } )/ ${ scope } /*.ts` ) ;
93+ await util . removeRecursively ( `./dist/**/*/ ${ config . scope } /*.ts` ) ;
8294}
8395
8496
8597/**
8698 * Re-runs Rollup on the downleveled ES5 to produce a UMD bundle
8799 */
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+
90105 const rollupArgs = [
91106 `-c ./modules/${ pkg } /rollup.config.js` ,
92107 `--sourcemap` ,
93108 ] ;
94109
95110 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` ) ;
97112 } ) ;
98113}
99114
@@ -103,7 +118,7 @@ export async function createUmdBundles({packages}: Config) {
103118 * leaving any type definition files in place
104119 */
105120export async function cleanTypeScriptFiles ( config : Config ) {
106- const tsFilesGlob = './dist/packages/**/*.js ' ;
121+ const tsFilesGlob = './dist/packages/**/*.ts ' ;
107122 const dtsFilesFlob = './dist/packages/**/*.d.ts' ;
108123 const filesToRemove = await util . getListOfFiles ( tsFilesGlob , dtsFilesFlob ) ;
109124
@@ -117,12 +132,14 @@ export async function cleanTypeScriptFiles(config: Config) {
117132 * Renames the index files in each package to the name
118133 * of the package.
119134 */
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+
122139 const files = await util . getListOfFiles ( `./dist/packages/${ pkg } /index.**` ) ;
123140
124141 for ( let file of files ) {
125- const target = file . replace ( 'index' , pkg ) ;
142+ const target = file . replace ( 'index' , bottomLevelName ) ;
126143 util . copy ( file , target ) ;
127144 util . remove ( file ) ;
128145 }
@@ -133,7 +150,9 @@ export async function renamePackageEntryFiles({packages}: Config) {
133150/**
134151 * Removes any remaining source map files from running NGC
135152 */
136- export async function removeRemainingSourceMapFiles ( { packages} : Config ) {
153+ export async function removeRemainingSourceMapFiles ( config : Config ) {
154+ const packages = util . getTopLevelPackages ( config ) ;
155+
137156 await util . removeRecursively ( `./dist/packages/?(${ packages . join ( '|' ) } )/**/*.map` ) ;
138157}
139158
@@ -142,7 +161,8 @@ export async function removeRemainingSourceMapFiles({packages}: Config) {
142161 * Copies the type definition files and NGC metadata files to
143162 * the root of the distribution
144163 */
145- export async function copyTypeDefinitionFiles ( { packages} : Config ) {
164+ export async function copyTypeDefinitionFiles ( config : Config ) {
165+ const packages = util . getTopLevelPackages ( config ) ;
146166 const files = await util . getListOfFiles ( `./dist/packages/?(${ packages . join ( '|' ) } )/**/*` ) ;
147167
148168 for ( let file of files ) {
@@ -157,17 +177,19 @@ export async function copyTypeDefinitionFiles({packages}: Config) {
157177/**
158178 * Creates minified copies of each UMD bundle
159179 */
160- export async function minifyUmdBundles ( { packages } : Config ) {
180+ export async function minifyUmdBundles ( config : Config ) {
161181 const uglifyArgs = [
162182 '-c' ,
163183 '-m' ,
164184 '--screw-ie8' ,
165185 '--comments' ,
166186 ] ;
167187
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` ;
171193
172194 return util . exec ( 'uglifyjs' , [
173195 ...uglifyArgs ,
@@ -184,17 +206,29 @@ export async function minifyUmdBundles({packages}: Config) {
184206 * Copies the README.md, LICENSE, and package.json files into
185207 * each package
186208 */
187- export async function copyPackageDocs ( { packages} : Config ) {
209+ export async function copyDocs ( config : Config ) {
210+ const packages = util . getTopLevelPackages ( config ) ;
211+
188212 for ( let pkg of packages ) {
189213 const source = `./modules/${ pkg } ` ;
190214 const target = `./dist/${ pkg } ` ;
191215
192- util . copy ( `${ source } /package.json` , `${ target } /package.json` ) ;
193216 util . copy ( `${ source } /README.md` , `${ target } /README.md` ) ;
194217 util . copy ( './LICENSE' , `${ target } /LICENSE` ) ;
195218 }
196219}
197220
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+
198232
199233/**
200234 * Removes the packages folder
@@ -208,7 +242,7 @@ export async function removePackagesFolder(config: Config) {
208242 * Deploy build artifacts to repos
209243 */
210244export async function publishToRepo ( config : Config ) {
211- for ( let pkg of config . packages ) {
245+ for ( let pkg of util . getTopLevelPackages ( config ) ) {
212246 const SOURCE_DIR = `./dist/${ pkg } ` ;
213247 const REPO_URL = `git@github.com:ngrx/${ pkg } -builds.git` ;
214248 const REPO_DIR = `./tmp/${ pkg } ` ;
0 commit comments