You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
All unit tests fail in ES6 due to prototype-less factory in jit compiler #14808
[ X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Note: Related to #13614 and #13853
Although arguably a duplicate, I filed this separate because it could be easily fixed by changing the signature to unblock unit tests separate from the underlying issue. Also, I believe this shows that the unifying issue is ES6 implementation.
Current behavior
ES6 distributions will result in certain syntax of anonymous functions to not have a prototype. The JIT compiler here uses a signature for useFactory that fails all unit tests here.
Expected behavior
First, to unblock ES6 unit tests. Second, to handle factories without prototypes.
Minimal reproduction of the problem with instructions
Plunk here
Shows failure in es6. Change everything to es5 distributions and it works.
Yup, we were at 6 and dropped to 5 for ng4. I think if I recall JIT output es5 but worked fine with eS6, whereas AOT is outputing full es6 with class and super calls. It's not devastating, but we do miss a few things like generators.
The error that you are seeing is because the generated code tries to inherit from a class located in @angular/core. As our generated code is ES5, it just does a <SuperCtor>.call(this, ...), which does not work with ES6.
This worked in v2.x though, as Angular used to shipp ES5 code with ESM (EcmaScript modules, i.e. import / export) for all .js files in the @angular/* npm packages (e.g. @angular/core/src/animation_player.js).
In v4.x, Angular started to ship real ES6 code with ESM in the *.js files. We are still shipping ES5 + ESM code in *.es5.js files (this is what I changed in the plunker).
To unblock you, please switch to these instead. Eventually, we will add a true ES6 emit for our jit compiler too, but we are not there yet. I created #15127 to track this.
Activity
tbosch commentedon Mar 10, 2017
Did this work in 2.x? As far as I know, our jit mode never worked with ES6 yet...
EricABC commentedon Mar 10, 2017
Yup, we were at 6 and dropped to 5 for ng4. I think if I recall JIT output es5 but worked fine with eS6, whereas AOT is outputing full es6 with class and super calls. It's not devastating, but we do miss a few things like generators.
tbosch commentedon Mar 13, 2017
Here is a plunker that works: https://plnkr.co/edit/CSZEZ1VtyWofjDcKgzaw?p=preview
The error that you are seeing is because the generated code tries to inherit from a class located in
@angular/core. As our generated code is ES5, it just does a<SuperCtor>.call(this, ...), which does not work with ES6.This worked in v2.x though, as Angular used to shipp ES5 code with ESM (EcmaScript modules, i.e.
import/export) for all.jsfiles in the@angular/*npm packages (e.g. @angular/core/src/animation_player.js).In v4.x, Angular started to ship real ES6 code with ESM in the
*.jsfiles. We are still shipping ES5 + ESM code in*.es5.jsfiles (this is what I changed in the plunker).To unblock you, please switch to these instead. Eventually, we will add a true ES6 emit for our jit compiler too, but we are not there yet. I created #15127 to track this.
EricABC commentedon Mar 13, 2017
Thanks!
tbosch commentedon Mar 14, 2017
Closing, and tracking ES6 output in #15127
angular-automatic-lock-bot commentedon Sep 11, 2019
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.