-
Notifications
You must be signed in to change notification settings - Fork 12k
ng build --prod results in that the running app report "TypeError: Assignment to constant variable" with target:es2015 #9495
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
Comments
I have the same issue. Only way is targeting ES5. I haven't gotten a chance to create a demo client to reproduce this issue. Thanks for making it. |
I have the same problem. |
I too have the same issue. |
Same here. |
I have the same problem. |
Same issue here, resolved by using es5 as target. |
Same. |
Same issue here with https://github.com/coryrylan/ng-pokedex |
I had the same problem, when target was ES2015. But app compiles and works with:
I'm using "@angular/cli": "^1.7.0", "@angular/compiler": "^5.2.5" |
Same issue :( |
Same Issue |
Same Issue. HttpClient seems to be the trigger. Targeting es5 seems to fix the issue but you must change it in the tsconfig.app.json file as well as the tsconfig.json file in the root. |
Ditto. Same error after upgrading CLI to 1.7.0. Switching from es6 to es5 target appears to fix the problem. |
This is happening with CLI 1.6.8 also, so not sure that it is limited to 1.7.0. |
This issue is stopping es2015 from becoming popular. Currently I have 2 NG2+ projects: project A needs to support IE which dose not support es2015, and project B is LOB which has no need to support IE. The 2nd one should had enjoyed es2015 without polyfill. Project B used to be working well with es2015 with SystemJS. Now with NG Cli I had to reverse back to es5. |
Facing the same issue. This became a showstopper for me. Please suggest a fix for this issue ASAP. |
For me targeting es5 in tsconfig.json rather than es6 solved the issue. |
As of CLI 1.7.1 and the Angular 5.2.6, the problem still persists. |
I'm seeing this issue with the |
Same here: Workaround in my case is was reverting from I think problem is in |
Same here, anyone knowns a workaround?
|
Just updated to the newly-released CLI 1.7.2 and Angular 5.2.7. The problem persists. |
Update to Angular 6.0.0-beta.6 and same problem still there. Solution:
Any news on this from @angular ?? It makes the new httpClientModule a bit useless :( |
According to mishoo/UglifyJS#2949, the cause is in UglifyJS2 which has a switch to workaround, however, NG CLI is not exposing this switch, while it is using UtlifyJS2. According to the comment by kzc, NG CLI may just provide a switch to fix the problem, or simply use that switch by default for target es2015. |
In angular/angular#21948, Cito had suggested: "Same problem here with Angular-CLI 1.7.2. When I set conditionals: false to const uglifyCompressOptions = { ... } in node_modules/@angular/cli/models/webpack-configs/production.js, as suggested by @trotyl, the problem disappears." Hopefully Angular CLI team will provide a solution soon. |
Can someone of the cli team tell us what the plan is?
This would be a quick fix, but would work for me. Just mentioning @filipesilva 😏 |
As a workaround, I've added this to my build job, after I run npm install:
|
can confirm clydin's merge (and subsequent angular cli v. 1.7.3) fixed it. ...at least for me. |
Can also confirm that angular cli v. 1.7.3 fixed this issue. |
Closing this as resolved. If anyone is still encountering issues while using 1.7.3 within a project, please open a new issue detailing the problem. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
The tsconfig.json defined
target:es2015
package.json:
Repro steps
Find the simple heros demo app at https://github.com/zijianhuang/webapiclientgen, and locate DemoNGCli
or the demo app downloadable in https://angular.io/tutorial/toh-pt6
Go to respective source folder and run ng build --prod
Run the app with IIS, or you may try Apache or other Web server. And use Chrom or alike browse the app.
Observed behavior
The app will misbehave, with the following console traces when making the first HttpClient call.
ERROR TypeError: Assignment to constant variable. at r (main.14d23ee13c3a14c67d46.bundle.js:1) at XMLHttpRequest.a (main.14d23ee13c3a14c67d46.bundle.js:1) at e.invokeTask (polyfills.8e8e9e6cb9f95b7ba9ab.bundle.js:1) at Object.onInvokeTask (main.14d23ee13c3a14c67d46.bundle.js:1) at e.invokeTask (polyfills.8e8e9e6cb9f95b7ba9ab.bundle.js:1) at t.runTask (polyfills.8e8e9e6cb9f95b7ba9ab.bundle.js:1) at t.invokeTask [as invoke] (polyfills.8e8e9e6cb9f95b7ba9ab.bundle.js:1) at _ (polyfills.8e8e9e6cb9f95b7ba9ab.bundle.js:1) at XMLHttpRequest.k (polyfills.8e8e9e6cb9f95b7ba9ab.bundle.js:1)
The HttpClient call is actually successful with status 200 returned.
Desired behavior
Heros display.
Mention any other details that might be useful (optional)
ng build --prod --no-aot
will result in similar errors:Uncaught TypeError: Assignment to constant variable. at ih._compileModule (vendor.defd7bfff770299239f9.bundle.js:1) at j.then (vendor.defd7bfff770299239f9.bundle.js:1) at Object.then (vendor.defd7bfff770299239f9.bundle.js:1) at ih._compileModuleAndComponents (vendor.defd7bfff770299239f9.bundle.js:1) at ih.compileModuleAsync (vendor.defd7bfff770299239f9.bundle.js:1) at useClass.compileModuleAsync (vendor.defd7bfff770299239f9.bundle.js:1) at ls.bootstrapModule (vendor.defd7bfff770299239f9.bundle.js:1) at Object.cDNt (main.98d929d5770520d2cd22.bundle.js:1) at o (inline.66056c9a0e270b3547d6.bundle.js:1) at Object.0 (main.98d929d5770520d2cd22.bundle.js:1)
ng build --aot
is fine.ng build
is fine.When the tsconfig.json defined
target:es5
,ng build --prod
results in correct behavior in runtime.The text was updated successfully, but these errors were encountered: