Skip to content

refactor(@angular/build): unify and deduplicate emitFilesToDisk across builders - #34326

Merged
alan-agius4 merged 3 commits into
angular:mainfrom
alan-agius4:refactor/deduplicate-emit-files-to-disk
Oct 13, 2026
Merged

alan-agius4 merged 3 commits into
angular:mainfrom
alan-agius4:refactor/deduplicate-emit-files-to-disk

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Relocate emitFilesToDisk into src/utils/emit-files-to-disk.ts and unify the file emission descriptor shape across the application and library builders around origin ('memory' | 'disk') and source.

Update emitFilesToDisk to manage per-invocation parent directory creation internally with bounded concurrency, allowing application/index.ts, library/pipeline/build-action.ts, and utils/test-files.ts to share the same helper. This also removes the cross-rebuild directoryExists cache from the library builder's SingleBuildState so deleted output subdirectories are properly recreated during watch mode rebuilds.

…s builders

Relocate emitFilesToDisk into src/utils/emit-files-to-disk.ts and unify the file emission descriptor shape across the application and library builders around origin ('memory' | 'disk') and source.

Update emitFilesToDisk to manage per-invocation parent directory creation internally with bounded concurrency, allowing application/index.ts, library/pipeline/build-action.ts, and utils/test-files.ts to share the same helper. This also removes the cross-rebuild directoryExists cache from the library builder's SingleBuildState so deleted output subdirectories are properly recreated during watch mode rebuilds.

@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 file emission to disk by consolidating the logic into a shared emitFilesToDisk utility and updating various builders to use it. It also renames inputPath to source in disk file interfaces and adds corresponding tests. The review feedback highlights two key issues in the new utility: first, fs.promises.cp does not support the mode option, rendering the COPYFILE_FICLONE flag a silent no-op, so copyFile should be used instead; second, using a Set to track directory existence under concurrent execution introduces a race condition, which can be resolved by caching directory creation promises in a Map.

Comment thread packages/angular/build/src/utils/emit-files-to-disk.ts
Comment thread packages/angular/build/src/utils/emit-files-to-disk.ts Outdated
Comment thread packages/angular/build/src/utils/emit-files-to-disk.ts Outdated
Comment thread packages/angular/build/src/utils/emit-files-to-disk.ts
@alan-agius4 alan-agius4 added the target: minor This PR is targeted for the next minor release label Oct 13, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 13, 2026 10:59
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 13, 2026
@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 Oct 13, 2026
@alan-agius4
alan-agius4 merged commit 4951994 into angular:main Oct 13, 2026
39 of 40 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

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

@alan-agius4
alan-agius4 deleted the refactor/deduplicate-emit-files-to-disk branch October 13, 2026 14:52
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.

2 participants