Skip to content

All unit tests fail in ES6 due to prototype-less factory in jit compiler #14808

Closed

Description

@EricABC

I'm submitting a ... (check one with "x")

[ 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.

  • Angular version: 4.0.0-rc.1

  • Browser: [Chrome@latest, edge]

  • Language: [ES6]

Activity

  1. added
    area: coreIssues related to the framework runtime
    regressionIndicates than the issue relates to something that worked in a previous version
    on Mar 1, 2017
  2. added this to the milestone on Mar 1, 2017
  3. tbosch commented on Mar 10, 2017

    @tbosch
    Contributor

    Did this work in 2.x? As far as I know, our jit mode never worked with ES6 yet...

  4. EricABC commented on Mar 10, 2017

    @EricABC
    Author

    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.

  5. tbosch commented on Mar 13, 2017

    @tbosch
    Contributor

    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 .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.

  6. self-assigned this
    on Mar 13, 2017
  7. removed
    regressionIndicates than the issue relates to something that worked in a previous version
    on Mar 13, 2017
  8. removed their assignment
    on Mar 13, 2017
  9. EricABC commented on Mar 13, 2017

    @EricABC
    Author

    Thanks!

  10. tbosch commented on Mar 14, 2017

    @tbosch
    Contributor

    Closing, and tracking ES6 output in #15127

  11. angular-automatic-lock-bot commented on Sep 11, 2019

    @angular-automatic-lock-bot

    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.

  12. locked and limited conversation to collaborators on Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions