Skip to content

Adding an ES2015/6/7 runtime.  #14393

Closed
Closed

Description

@SanderElias
[ x] feature request

Current behavior
Angular (and all its dependencies) are compiled down to ES5

Expected behavior
Compile everything down to ES2015. I (and more and more Angular users) am only supporting evergreen browsers. Those all have 95%+ support of es6, heck most have even es2016, and es2017 features are getting close too!

What is the motivation / use case for changing the behavior?
Using ES6 over es5 has the following:

  1. smaller runtime
  2. less (to none) polyfills
  3. faster execution. (I know not everything is faster now, actually for a lot of features it's actually opposite, but browsers are improving really fast, an ES6 support is getting faster and faster. This is high on the agenda of browser vendors)
  4. did I mention SMALLER runtime yet?
  5. easier to shake (I'm not too sure on this though.)
  6. the happy feeling of using modern, up to date stuff
  7. much smaller source maps, so faster for development too.
  8. more readable code in the runtime

To be clear, what I want is an Angular runtime that targets ES2015+ instead of ES5. I know I can do this for my portion of a project, but what I want is to ship an entire ES6 app to the browser. When your target is modern browsers, you should ship modern JS.

Activity

  1. DzmitryShylovich commented on Feb 10, 2017

    @DzmitryShylovich
    Contributor

    Not sure how it's related to angular.

    Angular is written in typescript. So you can compile it to es2015 by adding "target": "es2015" in tsconfig.json

  2. SanderElias commented on Feb 10, 2017

    @SanderElias
    ContributorAuthor

    @DzmitryShylovich That works for my part of the project, And that is assuming I'm also using typescript.
    (while I do that, not all developers are on the TS bandwagon).

    Then there is the testing. now all angular tests are run against the es5 version. If it were tested against the ES201(x) version, it will make clear what issues there are lurking in this area.

  3. SanderElias commented on Feb 10, 2017

    @SanderElias
    ContributorAuthor

    @trotyl Can you explain your downvote?

  4. trotyl commented on Feb 11, 2017

    @trotyl
    Contributor

    @SanderElias

    smaller runtime

    I don't think ES6 is being fully supported currently in minify tools, even clojure compiler supports only a few ES6 syntax. How can you get smaller runtime with not minified ES6 code compare to minified ES5 code? Or is there any dark magic I don't know yet?

    less (to none) polyfills

    Could you provide a little explain on this? AFAIK, the transpilation and polyfill are not coupled on TypeScript, and the transpilation process won't add polyfill, you need to add it yourself, so you don't need to include polyfill on modern browsers even if the code is transpiled.

  5. SanderElias commented on Feb 11, 2017

    @SanderElias
    ContributorAuthor

    @trotyl Thanks for the explanation!

    I don't think ES6 is being fully supported currently in minify tools, even clojure compiler supports only a few ES6 syntax. How can you get smaller runtime with not minified ES6 code compare to minified ES5 code? Or is there any dark magic I don't know yet?

    Well, compiling down to es5 blows the code up, and adds a fair amount of helpers. The minification is just something that will take some time. For now, its just babili that already does a pretty decent job, and this sort of thing will improve fast.

    Could you provide a little explain on this? AFAIK, the transpilation and polyfill are not coupled on TypeScript, and the transpilation process won't add polyfill, you need to add it yourself, so you don't need to include polyfill on modern browsers even if the code is transpiled.

    Typescript transpile's to ES5 and uses some internal polyfills. Especially around classes. And around generators too Just checked, those are not even available (anymore) if you compile to es5, This are just 2 of them, but there are more. But you are right, you can leave off some of the polyfills if you go to a modern browser, but not all of them.

  6. trotyl commented on Feb 11, 2017

    @trotyl
    Contributor

    Typescript transpile's to ES5 and uses some internal polyfills.

    I think you mean the tslib or ts-helpers funcs. It can be a problem if generated for every single file (and sadly Angular did), since Angular supports TypeScript 2.1 now, it should get rid of this problem soon.

  7. SanderElias commented on Feb 11, 2017

    @SanderElias
    ContributorAuthor

    I think you mean the tslib or ts-helpers funcs. It can be a problem if generated for every single file (and sadly Angular did), since Angular supports TypeScript 2.1 now, it should get rid of this problem soon.

    using es2015+ as target helps here too.
    here is a sample of what I mean with TS blows up code. I know typescript 2 solves it a bit. Again, all problems are solvable, but when you are targetting modern browsers, why would you?
    edit: the sample I have is functioning as is in the console of chrome! probably other browsers are following soon!

  8. tbosch commented on Apr 10, 2017

    @tbosch
    Contributor

    Angular is already publishing ES2015 code on npm. However, JIT does not work with this.

    Closing as a duplicate of #15127

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

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions