Skip to content

Commit f315e3e

Browse files
devversionjelbourn
authored andcommitted
build: fix random ngc resolve failures (#12103)
* Depending on the timing for building the assets and building the ESM output (kind of randomly), building the Material package will result in NGC failures. This happens when running the `material:build-no-bundles` task (e.g. unit testing; serving the dev-app) because the assets are built in parallel with the ESM output. * Removes a duplicated function in the package-tools.
1 parent 309f830 commit f315e3e

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

src/lib/tsconfig-tests.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"types": ["jasmine"],
1111
"paths": {
1212
"@angular/material/*": ["./*"],
13-
"@angular/cdk/*": ["../../dist/packages/cdk/*/public-api"]
13+
"@angular/cdk/*": ["../../dist/packages/cdk/*"]
1414
}
1515
},
1616
"angularCompilerOptions": {
@@ -24,6 +24,6 @@
2424
"index.ts"
2525
],
2626
"exclude": [
27-
"**/schematics/**/*.ts",
28-
],
27+
"**/schematics/**/*.ts"
28+
]
2929
}

tools/package-tools/build-package.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import {join} from 'path';
2-
import {red} from 'chalk';
32
import {PackageBundler} from './build-bundles';
43
import {buildConfig} from './build-config';
5-
import {getSecondaryEntryPointsForPackage} from './secondary-entry-points';
64
import {
75
addImportAsToAllMetadata,
86
compileEntryPoint,
97
renamePrivateReExportsToBeUnique,
108
} from './compile-entry-point';
11-
import {ngcCompile} from './ngc-compile';
9+
import {getSecondaryEntryPointsForPackage} from './secondary-entry-points';
1210

1311
const {packagesDir, outputDir} = buildConfig;
1412

@@ -78,7 +76,8 @@ export class BuildPackage {
7876

7977
/** Compiles the TypeScript test source files for the package. */
8078
async compileTests() {
81-
await this._compileTestEntryPoint(testsTsconfigName);
79+
return compileEntryPoint(this, testsTsconfigName)
80+
.then(() => addImportAsToAllMetadata(this));
8281
}
8382

8483
/** Creates all bundles for the package and all associated entry points. */
@@ -93,20 +92,6 @@ export class BuildPackage {
9392
.then(() => renamePrivateReExportsToBeUnique(this, p));
9493
}
9594

96-
/** Compiles the TypeScript sources of a primary or secondary entry point. */
97-
private _compileTestEntryPoint(tsconfigName: string, secondaryEntryPoint = ''): Promise<any> {
98-
const entryPointPath = join(this.sourceDir, secondaryEntryPoint);
99-
const tsconfigPath = join(entryPointPath, tsconfigName);
100-
101-
return ngcCompile(['-p', tsconfigPath])
102-
.then(() => addImportAsToAllMetadata(this))
103-
.catch(() => {
104-
const error = red(`Failed to compile ${secondaryEntryPoint} using ${tsconfigPath}`);
105-
console.error(error);
106-
return Promise.reject(error);
107-
});
108-
}
109-
11095
/** Stores the secondary entry-points for this package if they haven't been computed already. */
11196
private cacheSecondaryEntryPoints() {
11297
if (!this._secondaryEntryPoints) {

tools/package-tools/gulp/build-tasks-gulp.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ export function createPackageBuildTasks(buildPackage: BuildPackage, preBuildTask
6060
));
6161

6262
task(`${taskName}:build-no-bundles`, sequenceTask(
63+
// Build assets before building the ESM output. Since we compile with NGC, the compiler
64+
// tries to resolve all required assets.
65+
`${taskName}:assets`,
6366
// Build the ESM output that includes all test files. Also build assets for the package.
64-
[`${taskName}:build:esm:tests`, `${taskName}:assets`],
67+
`${taskName}:build:esm:tests`,
6568
// Inline assets into ESM output.
6669
`${taskName}:assets:inline`
6770
));

0 commit comments

Comments
 (0)