diff --git a/tools/package-tools/build-package.ts b/tools/package-tools/build-package.ts index 2ab4f5e94be3..9977fd5d98ce 100644 --- a/tools/package-tools/build-package.ts +++ b/tools/package-tools/build-package.ts @@ -3,6 +3,7 @@ import {spawn} from 'child_process'; import {readFileSync, writeFileSync} from 'fs'; import {sync as glob} from 'glob'; import {join} from 'path'; +import {main as ngc} from '@angular/tsc-wrapped'; import {PackageBundler} from './build-bundles'; import {buildConfig} from './build-config'; import {getSecondaryEntryPointsForPackage} from './secondary-entry-points'; @@ -82,7 +83,7 @@ export class BuildPackage { /** Compiles the TypeScript test source files for the package. */ async compileTests() { - await this._compileEntryPoint(testsTsconfigName); + await this._compileTestEntryPoint(testsTsconfigName); } /** Creates all bundles for the package and all associated entry points. */ @@ -108,6 +109,15 @@ export class BuildPackage { .then(() => this.renamePrivateReExportsToBeUnique(secondaryEntryPoint)); } + /** Compiles the TypeScript sources of a primary or secondary entry point. */ + private async _compileTestEntryPoint(tsconfigName: string, secondaryEntryPoint = '') { + const entryPointPath = join(this.sourceDir, secondaryEntryPoint); + const entryPointTsconfigPath = join(entryPointPath, tsconfigName); + + await ngc(entryPointTsconfigPath, {basePath: entryPointPath}); + this.renamePrivateReExportsToBeUnique(secondaryEntryPoint); + } + /** Renames `ɵa`-style re-exports generated by Angular to be unique across compilation units. */ private renamePrivateReExportsToBeUnique(secondaryEntryPoint = '') { // When we compiled the typescript sources with ngc, we do entry-point individually.