Skip to content

refactor(@angular/build): remove unnecessary realpath resolution for workspace root - #33661

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:refactor-workspace-root-realpath
Jul 28, 2026
Merged

refactor(@angular/build): remove unnecessary realpath resolution for workspace root#33661
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:refactor-workspace-root-realpath

Conversation

@clydin

@clydin clydin commented Jul 27, 2026

Copy link
Copy Markdown
Member

Previously, canonicalizePath resolved context.workspaceRoot using realpathSync unless preserveSymlinks was enabled. Resolving the workspace root was originally intended to align workspace paths with Node/TypeScript default physical file resolution, but created an unnecessary path asymmetry between preserveSymlinks settings and mutated the logical workspace path.

Furthermore, passing the resolved real path as absWorkingDir to esbuild caused esbuild to format metafile paths relative to the real path rather than the logical workspace root. This required workarounds to remap metafile paths back to the workspace root.

This change is safe today because Angular compiler plugins and path resolution utilities normalize relative paths dynamically without requiring workspaceRoot to be realpath'd. Removing realpathSync from canonicalizePath ensures workspaceRoot consistently remains the logical workspace path across all builders, esbuild natively formats metafile paths relative to workspaceRoot, and remapMetafileBasePath is no longer needed.

@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 simplifies path canonicalization by removing symbolic link resolution from canonicalizePath and deleting the remapMetafileBasePath utility along with its associated tests. Feedback on these changes includes removing the orphaned JSDoc block for the deleted remapMetafileBasePath function, cleaning up unused imports (toPosixPath and resolve) in bundler-context.ts, and expanding the test suite for canonicalizePath to cover Windows-specific drive-letter casing normalization.

Comment thread packages/angular/build/src/tools/esbuild/bundler-context.ts
Comment thread packages/angular/build/src/tools/esbuild/bundler-context.ts
Comment thread packages/angular/build/src/utils/path_spec.ts
…workspace root

Previously, `canonicalizePath` resolved `context.workspaceRoot` using `realpathSync` unless `preserveSymlinks` was enabled. Resolving the workspace root was originally intended to align workspace paths with Node/TypeScript default physical file resolution, but created an unnecessary path asymmetry between `preserveSymlinks` settings and mutated the logical workspace path.

Furthermore, passing the resolved real path as `absWorkingDir` to esbuild caused esbuild to format metafile paths relative to the real path rather than the logical workspace root. This required workarounds to remap metafile paths back to the workspace root.

This change is safe today because Angular compiler plugins and path resolution utilities normalize relative paths dynamically without requiring `workspaceRoot` to be realpath'd. Removing `realpathSync` from `canonicalizePath` ensures `workspaceRoot` consistently remains the logical workspace path across all builders, esbuild natively formats metafile paths relative to `workspaceRoot`, and `remapMetafileBasePath` is no longer needed.
@clydin
clydin force-pushed the refactor-workspace-root-realpath branch from ddd9bfc to bea7b63 Compare July 27, 2026 16:08
@clydin
clydin requested a review from alan-agius4 July 27, 2026 16:09
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 27, 2026
@alan-agius4 alan-agius4 added target: rc This PR is targeted for the next release-candidate 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 Jul 28, 2026
@alan-agius4
alan-agius4 merged commit 6c6bb21 into angular:main Jul 28, 2026
41 of 42 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: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants