-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Command
build
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Building a single locale which has a subpath results in Angular not being able to "find" the correct server to launch.
Minimal Reproduction
Link to reproduction repo: https://github.com/vzarskus/locale-manifest-issue
This repo has 2 locales: "en" on no subpath and "lt" on /lt subpath.
Scenario 1: running full build with both locales works:
Steps:
- Run
npm run build - Run
npm run serve:ssr:locale-manifest-issue - Open it in the browser
- Try changing url in url bar to /lt and back to /
- Everything should work
Scenario 2: running just EN build works:
Steps:
- Run
npm run build:en - Run
npm run serve:ssr:locale-manifest-issue - Open it in the browser
- Works (EN page is displayed)
Scenario 3: running just LT build does not work:
Steps:
- Run
npm run build:lt - Run
npm run serve:ssr:locale-manifest-issue - Open it in the browser
- Does not work (LT page is not displayed neither on /lt nor on root url)
Looking at the compiled output of Scenario 3, I can find the culprit in dist/locale-manifest-issue/server/server.mjs getEntryPointExportsForUrl function:
getEntryPointExportsForUrl(t) {
let { basePath: n } = this.manifest;
if (this.supportedLocales.length === 1) return this.getEntryPointExports(''); // <---- Delete this line
let r = cm(t, n);
return this.getEntryPointExports(r) ?? this.getEntryPointExports('');
}
When there's a single locale, Angular always just assumes that the entrypoint is in server root. However, for LT locale, the entrypoint is actually in lt folder (dist/locale-manifest-issue/server/lt/main.server.mjs).
Deleting the line marked with "// <---- Delete this line" comment fixes the issue. Meaning that visiting /lt now works as expected.
Exception or Error
Your Environment
Node: 22.17.0
Package Manager: npm 11.4.2
OS: linux x64
Angular: 20.3.9
... common, compiler, compiler-cli, core, forms, localize
... platform-browser, platform-server, router
Package Version
------------------------------------
@angular-devkit/architect 0.2003.8
@angular-devkit/core 20.3.8
@angular-devkit/schematics 20.3.8
@angular/build 20.3.8
@angular/cli 20.3.8
@angular/ssr 20.3.8
@schematics/angular 20.3.8
rxjs 7.8.2
typescript 5.9.3
Anything else relevant?
No response