Skip to content

Error building localized app with webpack when subPath option is used #30247

@frederic-septeo

Description

@frederic-septeo

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

When I build a localized angular application with the "@angular-devkit/build-angular:browser" builder and a subPath configured I get the following error :
Localized bundle generation failed: ENOENT: no such file or directory, open 'C:\......\newAngular\dist\new-angular\en-US\polyfills.7758a3fdbccf54e6.js'

The error occurs with a newly generated angular app and only with a webpack builder. The esbuild builder works fine.

Here is the full angular.json :

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "newAngular": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "i18n": {
        "sourceLocale": {
          "code": "en-US",
          "subPath": ""
        },
        "locales": {}
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/new-angular",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": [
              "zone.js",
              "@angular/localize/init"
            ],
            "tsConfig": "tsconfig.app.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "public"
              }
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "localize": true
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kB",
                  "maximumError": "1MB"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "4kB",
                  "maximumError": "8kB"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "newAngular:build:production"
            },
            "development": {
              "buildTarget": "newAngular:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n"
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": [
              "zone.js",
              "zone.js/testing",
              "@angular/localize/init"
            ],
            "tsConfig": "tsconfig.spec.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "public"
              }
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        }
      }
    }
  }
}

Minimal Reproduction

Create an empty angular application with ng new.
Set builder to @angular-devkit/build-angular:browser
Add localization package with ng add @angular/localize
Add i18n config in angular.json using the subPath option.
Launch build with ng build

Exception or Error

Localized bundle generation failed: ENOENT: no such file or directory, open 'C:\......\newAngular\dist\new-angular\en-US\polyfills.7758a3fdbccf54e6.js'

Your Environment

Angular CLI: 19.2.10
Node: 20.11.0
Package Manager: npm 10.2.4
OS: win32 x64

Angular: 19.2.9
... common, compiler, compiler-cli, core, forms, localize
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.10
@angular-devkit/build-angular   19.2.10
@angular-devkit/core            19.2.10
@angular-devkit/schematics      19.2.10
@angular/cli                    19.2.10
@schematics/angular             19.2.10
rxjs                            7.8.2
typescript                      5.7.3
zone.js                         0.15.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions