Skip to content

production mode with es2015 breaks angular/common/http in angular-cli 6 beta 5 #9989

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
benneq opened this issue Mar 16, 2018 · 2 comments
Closed

Comments

@benneq
Copy link

benneq commented Mar 16, 2018

Versions

<!--
Angular CLI: 6.0.0-beta.5
Node: 9.7.1
OS: darwin x64
Angular: 6.0.0-beta.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 6.0.0-beta.4
@angular/cli: 6.0.0-beta.5
@angular/flex-layout: 5.0.0-beta.13
@angular/material: 6.0.0-beta.4
@angular-devkit/build-optimizer: 0.4.5
@angular-devkit/core: 0.4.5
@angular-devkit/schematics: 0.4.5
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 6.0.0-beta.5
@schematics/angular: 0.4.5
@schematics/package-update: 0.4.5
typescript: 2.6.2
webpack: 4.0.1

Repro steps

  • Change tsconfig.json to es2015
  • Use angular-cli production mode ( ng serve ---target=production --environment=prod )
  • Use @angular/common/http
  • Make HTTP request

Observed behavior

TypeError: Assignment to constant variable.

In this line:

o = ("responseURL"in (n = n) && n.responseURL ? n.responseURL : /^X-Request-URL:/m.test(n.getAllResponseHeaders()) ? n.getResponseHeader("X-Request-URL") : null) || t.url;

The problem is (n = n). Because n is defined as const n = this.xhrFactory.build();

Here are the corresponding lines in the angular source code:
o = ... = url = ...: https://github.com/angular/angular/blob/c8a1a14b87e5907458e8e87021e47f9796cb3257/packages/common/http/src/xhr.ts#L147
n = n: https://github.com/angular/angular/blob/c8a1a14b87e5907458e8e87021e47f9796cb3257/packages/common/http/src/xhr.ts#L25

Desired behavior

No error ;-)

Mention any other details that might be useful (optional)

It looks like the error comes from function inlining.

But I'm not sure if this problem is part of angular itself, or the TypeScript Compiler, or Uglify, or angular-cli because of bad default production settings.

@clydin
Copy link
Member

clydin commented Mar 19, 2018

Fixed via angular/devkit#519

@clydin clydin closed this as completed Mar 19, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants