Skip to content

Commit a2bafc1

Browse files
committed
fixup! fix(@angular/build): improve library compilation diagnostics and skip redundant d.ts rebundling
1 parent 8815569 commit a2bafc1

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

‎packages/angular/build/src/builders/library/pipeline/compilation.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,7 @@ function updateEmittedFileCaches(
260260

261261
if (targetFiles.get(normalized) !== contents) {
262262
targetFiles.set(normalized, contents);
263-
if (!isDts) {
264-
changedEsmFiles.add(isMap ? normalized.slice(0, -4) : normalized);
265-
} else if (!isMap) {
266-
changedDtsFiles.add(normalized);
267-
}
263+
(isDts ? changedDtsFiles : changedEsmFiles).add(isMap ? normalized.slice(0, -4) : normalized);
268264
}
269265
}
270266

‎packages/angular/build/src/builders/library/pipeline/compilation_spec.ts‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ describe('compileLibrary pipeline', () => {
340340
expect(state.getAffectedFiles([partialNew])).toEqual(new Set([partialNew, compScss]));
341341
});
342342

343-
it('should not mark .d.ts as changed in changedDtsFiles when only .d.ts.map changed', async () => {
343+
it('should mark .d.ts as changed in changedDtsFiles when .d.ts.map changes', async () => {
344344
const dtsPath = '/workspace/projects/my-lib/src/lib/lib.component.d.ts';
345345
const dtsMapPath = '/workspace/projects/my-lib/src/lib/lib.component.d.ts.map';
346346
const jsPath = '/workspace/projects/my-lib/src/lib/lib.component.js';
@@ -379,22 +379,17 @@ describe('compileLibrary pipeline', () => {
379379
await output1.diagnosePromise;
380380

381381
expect(output1.changedEsmFiles).toEqual(new Set([jsPath]));
382-
expect(output1.changedDtsFiles.size).toBe(0);
383-
// The updated .d.ts.map content should still be stored in dtsFiles
382+
expect(output1.changedDtsFiles).toEqual(new Set([dtsPath]));
384383
expect(output1.dtsFiles.get(dtsMapPath)).toBe('{"version":3,"mappings":"AACA"}');
385384

386-
// Case 2: .d.ts content itself changes
385+
// Case 2: neither .d.ts nor .d.ts.map changed
387386
emitted = [
388-
{ filename: dtsPath, contents: 'export declare class LibComponent { id: string; }\n' },
389-
{ filename: dtsMapPath, contents: '{"version":3,"mappings":"AADA"}' },
387+
{ filename: dtsPath, contents: 'export declare class LibComponent {}\n' },
388+
{ filename: dtsMapPath, contents: '{"version":3,"mappings":"AACA"}' },
390389
];
391390
const output2 = await compileLibrary(createOptions(), bundler, state);
392391
await output2.diagnosePromise;
393392

394-
expect(output2.changedDtsFiles).toEqual(new Set([dtsPath]));
395-
expect(output2.dtsFiles.get(dtsPath)).toBe(
396-
'export declare class LibComponent { id: string; }\n',
397-
);
398-
expect(output2.dtsFiles.get(dtsMapPath)).toBe('{"version":3,"mappings":"AADA"}');
393+
expect(output2.changedDtsFiles.size).toBe(0);
399394
});
400395
});

0 commit comments

Comments
 (0)