Skip to content

fix(@angular/build): preserve duplicate bundle filenames across output file types - #33936

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:fix-duplicate-output-files
Aug 27, 2026
Merged

fix(@angular/build): preserve duplicate bundle filenames across output file types#33936
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:fix-duplicate-output-files

Conversation

@clydin

@clydin clydin commented Aug 26, 2026

Copy link
Copy Markdown
Member

When building applications with SSR and Service Worker enabled, bundle outputs (such as CSS chunks produced from JS imports) can share the same relative path name across different BuildOutputFileTypes (e.g. BuildOutputFileType.Browser and BuildOutputFileType.ServerApplication).

Previously, build results stored output files in a Record keyed by file path, which caused server files to overwrite browser files of the same name and prevented them from being emitted to the browser output directory.

The build Result interface now maintains files as an array (ResultFile[]), and rebuild tracking keys output files using a compound type and path key, ensuring all files are preserved and emitted correctly regardless of type.

Closes #33922

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 26, 2026
@clydin
clydin force-pushed the fix-duplicate-output-files branch 2 times, most recently from 1c9af29 to ab5ba26 Compare August 27, 2026 00:11
@clydin
clydin marked this pull request as ready for review August 27, 2026 00:11

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the build output representation across various Angular builders, changing the files structure from a record/dictionary to an array of ResultFile objects. This simplifies file iteration and processing, and resolves potential path collisions by keying previous output info with both type and path. The review feedback suggests a performance optimization in build-action.ts to defer the creation of ResultFile objects, avoiding unnecessary allocations for unchanged files.

Comment thread packages/angular/build/src/builders/application/build-action.ts Outdated
Comment thread packages/angular/build/src/builders/application/build-action.ts Outdated
…t file types

When building applications with SSR and Service Worker enabled, bundle outputs (such as CSS chunks produced from JS imports) can share the same relative path name across different `BuildOutputFileType`s (e.g. `BuildOutputFileType.Browser` and `BuildOutputFileType.ServerApplication`).

Previously, build results stored output files in a Record keyed by file path, which caused server files to overwrite browser files of the same name and prevented them from being emitted to the browser output directory.

The build `Result` interface now maintains `files` as an array (`ResultFile[]`), and rebuild tracking keys output files using a compound type and path key, ensuring all files are preserved and emitted correctly regardless of type.

Closes angular#33922
@clydin
clydin force-pushed the fix-duplicate-output-files branch from ab5ba26 to 2a7a2f7 Compare August 27, 2026 00:16
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 27, 2026
@clydin
clydin requested a review from alan-agius4 August 27, 2026 00:16
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 27, 2026
@alan-agius4
alan-agius4 merged commit 701bde4 into angular:main Aug 27, 2026
41 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

application builder writes ngsw.json entries for files only present in server dist (SSR + i18n + JS-import CSS)

2 participants