Is there any transpiler configuration/option available which transpiles ES6, e.g. for-of-loops to ES5 which is really usable on a production website? The best i found is to include an extra polyfill, which results in the at least double file size of the same functionality in vanilla ES5. Or is this transpiler idea for writing future esnext for nodejs stuff only?
Asked
Active
Viewed 618 times
0
-
3Plenty of production websites are using transpiled ES6 - https://babeljs.io/users/. – joews Oct 11 '15 at 19:36
-
You may be interested in http://davidwalsh.name/es6-features-testing - only load transpiled code for browsers without native ES6 support. – joews Oct 11 '15 at 19:41
-
Thanks @joews. Makes sense what he says. – bigbeee Oct 11 '15 at 20:18
-
@joews yeah sure they listed platforms do so, but they could even do that with nodejs and not for the browser js, wasn't so clear for me. – bigbeee Oct 11 '15 at 20:23
-
Certain ES6 features require not just transpiling, but require an ES6 environmnet. If you want an ES6 environment, you have to emulate it. If you want to emulate it, you have to load an emulator. If you don't want to load the emulator, then you can't emulate it. The babel polyfill is 85K minified. In today's world, that is small. – Oct 11 '15 at 23:03
-
Okay, got a clear picture what the limitations/side effects are of using ES6 transpiling at the moment. Thanks. – bigbeee Oct 12 '15 at 11:37
1 Answers
0
Talking about Babel specifically, if you want to reduce payload size you can stick to features that don't require polyfilling and you may be interested in the runtime transformer for consolidating helper code. You could try to squeeze out a bit more with optional transformers like minification.deadCodeElimination
and minification.constantFolding
, but I presume you're minifying your code anyway, which might already do some of that.

JMM
- 26,019
- 3
- 50
- 55
-
-
Thanks for your answer!. FYI, the links to the docs are broken and I can't find any good replacements.. – Tieme Dec 19 '15 at 22:54
-
Thanks @Tieme! I think I'll just update these links to point to the v6 documentation. If you need the v5 documentation there are some people hosting mirrors of it -- ask about it on the Babel Slack. – JMM Dec 21 '15 at 15:14
-
Cool. I already found the v5 examples. I hope you can find nice v6 examples! – Tieme Dec 21 '15 at 15:20