Skip to content

Launching a single locale with subpath does not work without hacks #31675

@vzarskus

Description

@vzarskus

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:

  1. Run npm run build
  2. Run npm run serve:ssr:locale-manifest-issue
  3. Open it in the browser
  4. Try changing url in url bar to /lt and back to /
  5. Everything should work

Scenario 2: running just EN build works:
Steps:

  1. Run npm run build:en
  2. Run npm run serve:ssr:locale-manifest-issue
  3. Open it in the browser
  4. Works (EN page is displayed)

Scenario 3: running just LT build does not work:
Steps:

  1. Run npm run build:lt
  2. Run npm run serve:ssr:locale-manifest-issue
  3. Open it in the browser
  4. 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

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions