Skip to content

Commit 0bc182b

Browse files
committed
fixup! fix(@angular/build): enforce library compilerOptions and skip unused .tsbuildinfo emit
1 parent 562ec50 commit 0bc182b

3 files changed

Lines changed: 8 additions & 11 deletions

File tree

‎packages/angular/build/src/builders/library/tests/behavior/build_spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
237237
);
238238
});
239239

240-
it('should succeed without emitting .tsbuildinfo in the persistent cache directory when cache is enabled', async () => {
240+
it('should write and reuse .tsbuildinfo in the persistent cache directory when cache is enabled', async () => {
241241
harness.useProject('lib', {
242242
root: 'projects/lib',
243243
sourceRoot: 'projects/lib/src',
@@ -258,7 +258,7 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) =>
258258
expect(firstBuild.result?.success).toBeTrue();
259259
harness
260260
.expectFile('.angular/cache/0.0.0-PLACEHOLDER/lib/angular-build-library/.tsbuildinfo')
261-
.toNotExist();
261+
.toExist();
262262

263263
await harness.writeFile(
264264
'projects/lib/src/public-api.ts',

‎packages/angular/build/src/tools/angular/compilation/angular-compilation_spec.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import path from 'node:path';
910
import ts from 'typescript';
1011
import type { AngularHostOptions } from '../angular-host';
1112
import { CompilerOptionOverrides, transformCompilerOptions } from './compiler-options';
@@ -480,7 +481,7 @@ describe('AngularCompilation', () => {
480481
expect(compilerOptions.composite).toBe(false);
481482
});
482483

483-
it('enforces library compiler options and skips app-only target warning and .tsbuildinfo', () => {
484+
it('enforces library compiler options and skips app-only target warning', () => {
484485
const { compilerOptions, warnings } = transformCompilerOptions(
485486
ts,
486487
{
@@ -502,8 +503,8 @@ describe('AngularCompilation', () => {
502503
expect(compilerOptions.noEmit).toBe(false);
503504
expect(compilerOptions.emitDeclarationOnly).toBe(false);
504505
expect(compilerOptions.emitDecoratorMetadata).toBe(false);
505-
expect(compilerOptions.incremental).toBe(false);
506-
expect(compilerOptions.tsBuildInfoFile).toBeUndefined();
506+
expect(compilerOptions.incremental).toBe(true);
507+
expect(compilerOptions.tsBuildInfoFile).toBe(path.join('/tmp/cache', '.tsbuildinfo'));
507508
expect(warnings).toEqual([]);
508509
});
509510
});

‎packages/angular/build/src/tools/angular/compilation/compiler-options.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,13 @@ export function transformCompilerOptions(
7878
compilerOptions.compilationMode ??= 'partial';
7979
}
8080

81-
// Enable incremental compilation by default if caching is enabled and incremental is not explicitly disabled.
82-
// Library compilation does not reuse on-disk .tsbuildinfo files across builds because all JS and .d.ts
83-
// outputs must be emitted into in-memory maps on every cold build, while watch mode uses in-memory
84-
// BuilderProgram state directly.
85-
if (!isLibrary && compilerOptions.incremental !== false && overrides?.cachePath) {
81+
// Enable incremental compilation by default if caching is enabled and incremental is not explicitly disabled
82+
if (compilerOptions.incremental !== false && overrides?.cachePath) {
8683
compilerOptions.incremental = true;
8784
// Set the build info file location to the configured cache directory
8885
compilerOptions.tsBuildInfoFile = path.join(overrides.cachePath, '.tsbuildinfo');
8986
} else {
9087
compilerOptions.incremental = false;
91-
compilerOptions.tsBuildInfoFile = undefined;
9288
}
9389

9490
if (isLibrary) {

0 commit comments

Comments
 (0)