Skip to content

fix(@angular/build): align lazy route entry names with workspace root for SSR modulepreload - #34372

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/ssr-lazy-route-base-path
Open

alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:fix/ssr-lazy-route-base-path

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Override compilerOptions.basePath with build.initialOptions.absWorkingDir when initializing the Angular compilation so lazyRoutesTransformer computes ɵentryName relative to the workspace root rather than the tsconfig directory. This matches the workspace-relative keys in entryPointToBrowserMapping used for SSR modulepreload link generation when the application's tsconfig is not located at the workspace root.

Closes #34369

@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 introduces support for overriding the basePath compiler option in the Angular build process, ensuring it is correctly transformed to a Posix path and passed from esbuild's working directory. It also updates related tests to verify the basePath override and ensure that lazy route entry points match the ɵentryName in the server bundle. Feedback suggests falling back to process.cwd() if build.initialOptions.absWorkingDir is undefined, ensuring basePath aligns with esbuild's effective workspace root.

Comment thread packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Oct 16, 2026
@alan-agius4
alan-agius4 requested a review from clydin October 16, 2026 07:37
@alan-agius4
alan-agius4 force-pushed the fix/ssr-lazy-route-base-path branch from 8291fc5 to 8a02c48 Compare October 16, 2026 07:38
@alan-agius4 alan-agius4 added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Oct 16, 2026
… for SSR modulepreload

Override `compilerOptions.basePath` with `build.initialOptions.absWorkingDir` when initializing the Angular compilation so `lazyRoutesTransformer` computes `ɵentryName` relative to the workspace root rather than the tsconfig directory. This matches the workspace-relative keys in `entryPointToBrowserMapping` used for SSR `modulepreload` link generation when the application's `tsconfig` is not located at the workspace root.

Closes angular#34369
@alan-agius4
alan-agius4 force-pushed the fix/ssr-lazy-route-base-path branch from 8a02c48 to 997bf67 Compare October 16, 2026 07:40
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release and removed target: minor This PR is targeted for the next minor release target: patch This PR is targeted for the next patch release labels Oct 16, 2026
import type * as ng from '@angular/compiler-cli';
import type { PartialMessage } from 'esbuild';
import * as path from 'node:path';
import { join } from 'node:path';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Import doesn't seem to be used anywhere.

return {
compilerOptions: {
...compilerOptions,
basePath: overrides?.basePath ?? compilerOptions.basePath,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be converted to a posix path?

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

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

2 participants