From 0690f063cbecc2b2949f3b1a44906412a953c89e Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Mon, 12 Oct 2026 12:50:49 +0000 Subject: [PATCH 1/2] fix(@angular/build): filter Rolldown warnings and disable .d.ts annotation comments in library builder Suppress noisy Rolldown warnings (`EMPTY_BUNDLE`, `UNUSED_EXTERNAL_IMPORT`, and `THIS_IS_UNDEFINED`) and disable annotation comments in `.d.ts` output bundles to match `ng-packagr` behavior. --- .../src/builders/library/pipeline/bundler.ts | 16 +++++++- .../library/tests/behavior/build_spec.ts | 40 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/packages/angular/build/src/builders/library/pipeline/bundler.ts b/packages/angular/build/src/builders/library/pipeline/bundler.ts index d05f8b7e814f..a27aff1680af 100644 --- a/packages/angular/build/src/builders/library/pipeline/bundler.ts +++ b/packages/angular/build/src/builders/library/pipeline/bundler.ts @@ -300,6 +300,15 @@ function processRolldownOutput( return { filesToEmit, moduleIdsByBundle, tslibBundles }; } +/** + * Set of Rolldown warning codes that should be ignored. + */ +const IGNORED_ROLLDOWN_WARNING_CODES: ReadonlySet = new Set([ + 'EMPTY_BUNDLE', + 'UNUSED_EXTERNAL_IMPORT', + 'THIS_IS_UNDEFINED', +]); + /** * Executes a Rolldown bundle build across all provided entry inputs. * @@ -341,7 +350,12 @@ async function executeMultiBundle( resolve: { symlinks: !preserveSymlinks }, checks: { circularDependency: false }, onLog(level, log) { + // Ignore specified warning codes if (level === 'warn') { + if (log.code && IGNORED_ROLLDOWN_WARNING_CODES.has(log.code)) { + return; + } + warnings.push(log.message); } }, @@ -358,7 +372,7 @@ async function executeMultiBundle( chunkFileNames: `[name]-[hash].${extension}`, sourcemap, hoistTransitiveImports: false, - comments: { jsdoc: isDts, legal: true, annotation: true }, + comments: { jsdoc: isDts, legal: true, annotation: !isDts }, }); return { diff --git a/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts b/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts index 74150e57acb7..a19ced8c0309 100644 --- a/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts +++ b/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts @@ -74,6 +74,46 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) => ); }); + it('should not log EMPTY_BUNDLE warnings for type-only entry points', async () => { + await harness.writeFile( + 'projects/lib/src/public-api.ts', + `export interface OnlyType { id: string; }`, + ); + + harness.useTarget('build', { + ...BASE_OPTIONS, + }); + + const { result, logs } = await harness.executeOnce(); + expect(result?.success).toBeTrue(); + expect(logs.some((l) => l.level === 'warn')).toBeFalse(); + }); + + it('should preserve JSDoc comments in .d.ts and annotation comments in .mjs bundles', async () => { + await harness.writeFile( + 'projects/lib/src/public-api.ts', + ` + function identity(x: T): T { return x; } + /** Public API JSDoc comment */ + export const VALUE = /* @__PURE__ */ identity('test'); + `, + ); + + harness.useTarget('build', { + ...BASE_OPTIONS, + }); + + const { result } = await harness.executeOnce(); + expect(result?.success).toBeTrue(); + + const fesmContent = harness.readFile('dist/lib/fesm2022/lib.mjs'); + expect(fesmContent).toContain('@__PURE__'); + expect(fesmContent).not.toContain('Public API JSDoc comment'); + + const dtsContent = harness.readFile('dist/lib/types/lib.d.ts'); + expect(dtsContent).toContain('Public API JSDoc comment'); + }); + it('should automatically add tslib to dependencies when output chunks import tslib', async () => { await harness.writeFile( 'projects/lib/src/public-api.ts', From 6e1b951b2a04dc4347dbcbd62379f30054796bbf Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Mon, 12 Oct 2026 12:55:33 +0000 Subject: [PATCH 2/2] fixup! fix(@angular/build): filter Rolldown warnings and disable .d.ts annotation comments in library builder --- .../build/src/builders/library/tests/behavior/build_spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts b/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts index a19ced8c0309..996001db209d 100644 --- a/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts +++ b/packages/angular/build/src/builders/library/tests/behavior/build_spec.ts @@ -112,6 +112,7 @@ describeLibraryBuilder(executeLibraryBuilder, LIBRARY_BUILDER_INFO, (harness) => const dtsContent = harness.readFile('dist/lib/types/lib.d.ts'); expect(dtsContent).toContain('Public API JSDoc comment'); + expect(dtsContent).not.toContain('@__PURE__'); }); it('should automatically add tslib to dependencies when output chunks import tslib', async () => {