Skip to content

ng serve with a specific locale throws an error: $localize is not a function #30044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
mpo-dev opened this issue Apr 7, 2025 · 2 comments
Closed
1 task done
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@mpo-dev
Copy link

mpo-dev commented Apr 7, 2025

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

19.0.2

Description

After ng update-ing to the latest Angular CLI 19.2.5, running ng serve with a specific locale throws the following runtime error:

Uncaught TypeError: $localize is not a function

The error originates from one of my Angular libraries. The library is already added to the prebundle excludes and it used to work fine in Angular CLI 19.0.2. I've double checked this by downgrading to a 19.0.2 and rerunning ng serve, my application was served correctly and localized.

Minimal Reproduction

Running ng serve with a different locale configuration. In my case

"builder": "@angular-devkit/build-angular:application",
...
"localize": [
  "nl"
],

Exception or Error

mplusonline-common.mjs:993 Uncaught TypeError: $localize is not a function
    at mplusonline-common.mjs:993:9

Your Environment

Angular CLI: 19.2.5
Node: 20.11.1
Package Manager: npm 10.2.4
OS: darwin arm64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.5
@angular-devkit/build-angular   19.2.5
@angular-devkit/core            19.2.5
@angular-devkit/schematics      19.2.5
@angular/cdk                    19.2.7
@angular/cli                    19.2.5
@angular/material               19.2.7
@schematics/angular             19.2.5
rxjs                            7.8.1
typescript                      5.6.3
zone.js                         0.15.0

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label Apr 7, 2025
@mpo-dev
Copy link
Author

mpo-dev commented Apr 9, 2025

After trying to create a minimum reproduction repo for a while, I found out a new library dependency was added to one of our libraries and that specific library dependency was missing in the prebundle excludes. Now adding it, ng serve works fine again.

Maybe the Angular error can make it somehow a little clearer as to which library is causing the error? Anyway, as this was my own fault, I will close this issue.

@mpo-dev mpo-dev closed this as completed Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

2 participants