$localize runtime error with special .browserslistrc file

This issue has been created since 2022-11-21.

Which @angular/* package(s) are the source of the bug?

localize

Is this a regression?

Yes

Description

Since Angular 15, targeting last 5 iOS major versions using .browserslistrc file breaks the generated bundle, throwing TypeError: $localize is not a function on runtime.
Just changing .browserslistrc to last 4 iOS major versions generates valid bundles again.

To reproduce, follow this steps:

ng new
ng add @angular/localize

Then update .browserslistrc with this content: last 5 iOS major versions

Add "localize": true in your angular.json file, under projects > yourProject > architect > build > options.

Add an i18n attribute to some HTML element to enable localization.

And then:

ng serve

Please provide a link to a minimal reproduction of the bug

I haven't been able to reproduce on StackBlitz, it's ignoring my angular.json file

Please provide the exception or error you saw

TypeError: $localize is not a function

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 15.0.0
Node: 18.12.1
Package Manager: npm 9.1.2
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.0
@angular-devkit/build-angular   15.0.0
@angular-devkit/core            15.0.0
@angular-devkit/schematics      15.0.0
@schematics/angular             15.0.0
rxjs                            7.5.7
typescript                      4.8.4

Anything else?

No response

JoostK wrote this answer on 2022-11-21

Only the latest two majors of Safari are officially supported; so Safari 15 and 16 for Angular 15.

javiermarinros wrote this answer on 2022-11-21

It was the same for Angular 14, but it worked anyway for iOS 12 and 13 if configured using .browserslistrc to emit es6 code.

In Angular 15 trying to emit es6 compatible code ends up with this runtime error.

JoostK wrote this answer on 2022-11-21

ES6 (=ES2015), or ES5?

javiermarinros wrote this answer on 2022-11-21

ES2015

javiermarinros wrote this answer on 2022-11-21

We are having issues with our Angular 15 builds because the generated bundles use ES2020 features, like the Nullish Coalescing operator.

We were using this .browserslistrc

> 0.5%
last 2 versions
Firefox ESR
not dead
android > 5.0
last 5 iOS major versions
not IE > 0
not IE_Mob > 0

And it used to work just fine with Angular 14 builds, but with v15 builds are broken and the TypeError: $localize is not a function error is thrown. To fix it, we have to change iOS targeting to last 4 iOS major versions, but then the bundles use ES2020 features and break in some older devices.

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-12-01
Star Count 85220
Watcher Count 3042
Fork Count 22607
Issue Count 1316

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Replace htmLawed by HtmlPurifier 0 2022-01-20 2022-10-03
[AOC 2778X] Invalid display : DDC communication failed 4 2021-04-26 2022-11-02
Wrong contains logic in IpAddressString 5 2021-04-22 2022-11-11
Reintroduce Autotext button 2 2022-05-30 2022-10-15
encoder_sparseinst.py 中MyAdaptiveAvgPool2d函数疑似代码bug 1 2022-06-23 2022-10-09
[data grid] Blank space when using pagination with dynamic row height 1 2022-06-24 2022-10-05
consider using jpeg compression or zip compression to improve packet sending optimization (jpeg is better because the frame becomes much lighter). 0 2021-11-24 2022-11-27
Close tabs bar after unfocus with TZFocus 5 2021-06-03 2022-11-07
Tripple monitor setup not working 2 2021-12-16 2022-11-21
yas-snippet-dirs not loading automatically? 1 2021-03-08 2022-11-15
input type date not fill value 10 2020-08-25 2022-10-27
Reversed Each() / Reversed EachWithBreak() 1 2021-01-26 2022-11-12
Handle relations (i.e. geometry collections) corretly on geometry-filter 0 2022-08-08 2022-11-21
Alloca: "TypeError: as_pointer() missing 1 required positional arguement: 'self'" 4 2021-11-17 2022-11-22
Can't edit subject in the Automation `EmailNotificationAction` through Cloud UI 5 2022-05-11 2022-11-22
[textinput] Esc,L and Esc,U not finding word boundary 0 2022-03-16 2022-11-30
Jack-in doesn't handle a shadow-cljs config without builds 8 2022-04-17 2022-11-18
Storage phase: due payment parameter misuse 0 2021-09-16 2022-11-26
Implicit initialization causes defaults passed as method parameters to not be used 4 2022-01-16 2022-11-14
`AudioPlayer.setAsset` method should have `package` parameter 3 2022-11-03 2022-11-20
SECURITY! Byob is unsafe at the dropper and stager stage. 2 2021-06-06 2022-10-11
Remove retry related items and update secret path from SecretStore config 0 2021-06-02 2022-10-27
[BUG] Невозможность перемещения между з уровнями у симпл мобов 1 2021-10-29 2022-10-29
"Failed to register a ServiceWorker" on VSCode 1.61.0 1 2021-10-08 2022-11-15
`nearup` doesn't read `RUST_LOG` from environment 7 2021-12-15 2022-11-12
Mistake in german translation 5 2021-07-16 2022-11-29
www.fandroid.info 0 2021-11-04 2021-12-18
Wrong MAX_VERSION_CODE for android 2 2022-09-22 2022-10-22
Error response from daemon: pull access denied for rtdw/flink-base, repository does not exist or may require 'docker login': denied: requested access to the resource is denied 2 2021-12-14 2022-11-19
"ValueError: Invalid rule" with easylist filter 3 2016-10-17 2022-11-18
dotnet-trace Chromium|NetTrace|Speedscope 0 2022-01-11 2022-11-28
ESP crashing occasionally when started using WiFi and BLE at once (IDFGH-7858) 3 2022-07-19 2022-10-28
[Event Request] - OnBeforeExitGetPartnerIDFromJobEntry in Record 263 "Intrastat Jnl. Line" 1 2022-11-21 2022-11-17
SQL bitwise operators: &, |, ^... 2 2021-06-21 2022-11-17
Use rust for backend, unreal or unity frontend? 1 2021-01-26 2022-11-21
Never Use using namespace in a Header File 1 2021-12-01 2022-10-27
Arduino uno grbl variable spindle with S command doesn't work. 14 2018-04-06 2022-11-08
Fix navigation on Welcome event 2 2022-10-20 2022-10-16
Web - App crashes when login 17 2022-10-20 2022-10-16
Add extension to Open VSIX Repo 1 2021-07-20 2022-11-22
`Invalid LLVMRustVisibility value!` error on `cargo build` after upgrading from 1.53.0 to 1.54.0 16 2021-08-11 2022-11-15
[BUG]自定义代码片段,点击测试,系统卡死,希望MS系统能提供相关日志,知道问题什么原因,否则太影响测试速度了。 0 2022-04-13 2022-11-20
Receiver point is incorrect - Orlen Paczka 15 2021-10-08 2022-10-09
Bins at ends of chromosomes 2 2022-03-15 2022-11-14
Dark mode is not applied on log in page 3 2021-12-06 2022-10-03
[BUG] netmiko proxy exception depending on version installed 1 2022-08-01 2022-09-04
[BUG] modules.mac_brew_pkg incorrectly uses sudo -i 0 2022-07-28 2022-09-15
How to implement hot swap? 2 2017-11-10 2022-11-29
Type 65 queries are not cached 1 2022-01-25 2022-10-04
CP request: #96486 into stable 9 2022-03-01 2022-11-11