Skip to content

Compiler-generated factory doesn't call 'new', which fails for ES6. #14816

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

Current behavior
This line here calls '.callFn'. In a unit test, the DynamicTestModule module.ngfactory.js output will be jit_NgModuleInjector0.call(this, parent,[],[]);. This fails because NgModuleInjector is a class and needs to be called with 'new'.

Expected behavior
I believe '.instantiate' instead of '.callFn' needs to be called in some cases.

Minimal reproduction of the problem with instructions

See the plunk in #14808, however that issue currently blocks reproduction of this issue. If you modify the useFactory: () => ... to useFactory: function (... to bypass that issue, this issue should be the next one you hit. I tried to put up a gist for a modified compiler.js, but github doesn't seem to like the theta char used for the internal exports.

  • Angular version: 4.0.0-rc.1

  • Browser: [chrome]

  • 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

    To be clear, this is the place where we call the super constructor...

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

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

    Perhaps these two should be combined into one tracking JIT ES6 support, but duplicating now for completeness.

  6. tbosch commented on Mar 13, 2017

    @tbosch
    Contributor

    This is the same underlying problem / workaround as in #14808 (comment)

  7. self-assigned this
    on Mar 13, 2017
  8. added and removed
    regressionIndicates than the issue relates to something that worked in a previous version
    on Mar 13, 2017
  9. tbosch commented on Mar 14, 2017

    @tbosch
    Contributor

    Closing this and tracking ES6 support in #15127.

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

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

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions