Skip to content

@angular/cli v20.3.7 Pre-transform error: Failed to resolve import "angular:locale/data:en-150" from ".angular/vite-root/bpwebapp/polyfills.js". Does the file exist? #31579

@reifi

Description

@reifi

Command

serve

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

20.3.6

Description

When running ng serve after ng update working application to 20.3.7 I get:

15:05:32 [vite] (client) Pre-transform error: Failed to resolve import "angular:locale/data:en-150" from ".angular/vite-root/bpwebapp/polyfills.js". Does the file exist?
  Plugin: vite:import-analysis
  File: C:/some/bpwebapp/.angular/vite-root/bpwebapp/polyfills.js:1:7
  1  |  // angular:polyfills:angular:polyfills
  2  |  import "angular:locale/data:en-150";
     |          ^
  3  |  import "zone.js";
  4  |  import "@angular/localize/init";

This seems to have something to do with Fix Commit
8cdda11

At least for my non-SSR app this Angular 20.3.7 patch Version introduced a regression bug.

It's not very easy to understand if some config or setup has to change now.

In my angular.json there are polyfills for localize - but it seems it's not connected as nothing changes when I remove it:

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser-esbuild",
          "options": {
            "outputPath": "dist/bpwebapp",
            "baseHref": "/",
            "index": {
              "input": "src/index.websms.html",
              "output": "index.html"
            },
            "main": "src/main.ts",
            "polyfills": [
              "zone.js",
              "@angular/localize/init"
            ],
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
...

I already exclude libraries using localize in anglar.json:

...
"serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "buildTarget": "bpwebapp:build",
            "prebundle": {
              "exclude": [
                "@bpweb/error",
                "@bpweb/msisdn",
                "@bpweb/form-helper",
                "@bpweb/messaging"
              ]
            }
          },
...

in main.ts there is
/// <reference types="@angular/localize" />

Already a lot of strange config extras anyway, just to have multiple locales built.

Is it possible that it comes from libraries built with the old angular-cli ng-packagr?

It leaves me quite clueless what to do now - only having the in source comments of the commit 8cdda11

Minimal Reproduction

not reprodution yet

Exception or Error

15:05:32 [vite] (client) Pre-transform error: Failed to resolve import "angular:locale/data:en-150" from ".angular/vite-root/bpwebapp/polyfills.js". Does the file exist?
  Plugin: vite:import-analysis
  File: C:/some/bpwebapp/.angular/vite-root/bpwebapp/polyfills.js:1:7
  1  |  // angular:polyfills:angular:polyfills
  2  |  import "angular:locale/data:en-150";
     |          ^
  3  |  import "zone.js";
  4  |  import "@angular/localize/init";
at TransformPluginContext._formatLog (file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:31120:43)
    at TransformPluginContext.error (file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:31117:14)
    at normalizeUrl (file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:29604:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:29662:32
    at async Promise.all (index 0)
    at async TransformPluginContext.transform (file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:29630:4)
    at async EnvironmentPluginContainer.transform (file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:30919:14)
    at async loadAndTransform (file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:26057:26)
    at async viteTransformMiddleware (file:///C:/some/bpwebapp/node_modules/vite/dist/node/chunks/config.js:27132:20)

Your Environment

ngular CLI: 20.3.7
Node: 24.7.0
Package Manager: npm 11.5.1
OS: win32 x64


Angular: 20.3.7
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
... upgrade

Package                         Version
---------------------------------------
@angular-devkit/architect       0.2000.5
@angular-devkit/build-angular   20.3.7
@angular-devkit/core            20.3.7 (cli-only)
@angular-devkit/schematics      20.3.7
@angular/cdk                    20.2.10
@angular/material               20.2.10
@schematics/angular             20.3.7
rxjs                            7.8.2
typescript                      5.9.3
zone.js                         0.15.1

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