angular: Localized bundle generation failed: Unexpected return value from helper (expected a call expression)
π bug report
Affected Package
The issue is caused by package @angular/localize
Is this a regression?
the previous version in which this bug was not present was: Angular 8.x
Description
After upgrading the app to angular 9 and then 10 when I run ng build appName --configuration=production
localy it works. But the issue accoures on the gitLab pipeline
π₯ Exception or Error
Localized bundle generation failed: Unexpected return value from helper (expected a call expression)
Angular Version:
Angular CLI: 10.0.6
Node: 12.14.1
OS: darwin x64
Angular: 10.0.10
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: <error>
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.803.15
@angular-devkit/build-angular 0.1000.6
@angular-devkit/build-optimizer 0.1000.6
@angular-devkit/build-webpack 0.1000.6
@angular-devkit/core 10.0.6
@angular-devkit/schematics 10.0.6
@angular/cdk 8.2.3
@angular/cli 10.0.6
@angular/flex-layout 9.0.0-beta.29
@angular/http 7.2.16
@angular/material 8.2.3
@angular/material-moment-adapter 8.2.3
@ngtools/webpack 10.0.6
@schematics/angular 8.3.29
@schematics/update 0.1000.6
rxjs 6.6.2
typescript 3.9.7
webpack
Anything else relevant?
import in pollyfills.ts:
/* Load
and package.json: $localize
onto the global scope - used if i18n tags appear in Angular templates.*/
import β@angular/localize/initβ;β@angular/localizeβ: β^10.0.10β,
But in other hand, Iβ am still not using $localize
in typescript and in HTML to implement the new i18n translation. I still keep the previous implementation for i18n translation. Using $localize will be the next step after getting rid of the this issue/error.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 35 (18 by maintainers)
Glad you got to the bottom of it!! Thanks for working with me on this.
I would say that you must update those
peerDependencies
directly. The Angular framework peer dependencies should update themselves automatically when usingng update @angular/core
since it contains information about how to do that. But if you have a library that has apeerDependency
, it would be up to you to do the update manually.What are
preDependencies
? Do you meanpeerDependencies
?That is interesting. It is likely that the optimization is somehow changing the code to make it unparsable by the the i18n message translator. It is really hard for me to help without further information. Perhaps you could try removing parts of the application (and removing libraries) until you get it to work, then we might be able to nail down what is causing the problem.
Iβll give it a try, but I think should be:
node node_modules/.bin/ngc -p src/tsconfig.app.json
And yes. Itβs there in couple of.JS
files generated from.TS
files:OK, great. Let me take a look at that. I wonder why these are in vendor.js rather than main.js??
Correction: There is no main.es5.js generated. I do get just a file:
main.js
, but there I donβt find any$localize
. A $localize call existst just invendor.js
:(Pete: I updated this post to use backticks for the code block to make it more readable)