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
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:
smaller runtime
less (to none) polyfills
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)
did I mention SMALLER runtime yet?
easier to shake (I'm not too sure on this though.)
the happy feeling of using modern, up to date stuff
much smaller source maps, so faster for development too.
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.
@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.
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.
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 tooJust 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.
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.
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!
Activity
DzmitryShylovich commentedon Feb 10, 2017
Not sure how it's related to angular.
Angular is written in typescript. So you can compile it to es2015 by adding
"target": "es2015"intsconfig.jsonSanderElias commentedon Feb 10, 2017
@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.
SanderElias commentedon Feb 10, 2017
@trotyl Can you explain your downvote?
trotyl commentedon Feb 11, 2017
@SanderElias
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?
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.
SanderElias commentedon Feb 11, 2017
@trotyl Thanks for the explanation!
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.
Typescript transpile's to ES5 and uses some internal polyfills. Especially around classes.
And around generators tooJust 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.trotyl commentedon Feb 11, 2017
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.
SanderElias commentedon Feb 11, 2017
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!
tbosch commentedon Apr 10, 2017
Angular is already publishing ES2015 code on npm. However, JIT does not work with this.
Closing as a duplicate of #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.