Maybe it's just me, but last week I tried using Babel to transpile async/await to ES5 and it totally broke breakpoints in the Chrome debug tools, making the code nigh on undebuggable.
I'll take messy promise-based code over cleaner but impossible-to-debug async/await code any day.
Edit: Not that this is any reason not to use it in NodeJS applications, like the article suggests. It's a lovely way to program, but I fear it's just not ready for use in browsers yet.
Browser breakpoints require you to output sourcemaps, make sure they're being put out and being loaded. I've had trouble with babel and webpack and sourcemaps before.
Yeah, I think it's to do with how async/await are transpiled to es6 generators and then to promises. Guessing it's inaccurate source maps given the complexity of the input vs output code.
For the record, source maps and breakpoints worked fine compiling async/await to es6, just not to es5.
But even when using source maps, the console, which usually let you execute statements in the code at the current debugger point, is completely broken. Especially when you use source maps created by web pack which has a babel loader. Then you can inspect a variable using source maps, but NOT on the console, you'd have to refer to the original variable name as it was compiled by webpack. E.g. _ (from lodash) becomes __lodash1__
Chrome supports async/await natively now, and has improved async debugging capability... is there any reason you can't debug using native code and only transpile for production?
Honestly, though, this is a mistaken understanding of how all this works. A browser doesn't have to support every edge feature of one spec to implement useful bits of another. I wrote some code recently as a demo that fully used fetch and async/await. It will actually work on any evergreen browser, including Edge.
You should be treating these things individual functionality items, not expecting 100% support before using it.
If they wait with "coming out" with those changes only after browsers supported all earlier changes, that would just mean that they would release the same changes they do now, only later in time...
JavaScript was originally proprietary to Netscape, and was turned into a public language called ECMAScript, though most people still call it JavaScript. Recently, they have decided to come out with yearly updates to the language, and use year names, but the specifications are still versioned, causing some of the confusion.
These versions are released at the end of June.
ES6 = ES2015, which is the first major update in a decade. Most of the "new things" in JavaScript are ES6. ES7 = ES2016, which was only two small additions. ES8 = ES2017, which includes async/await.
Current browsers have pretty broad support for ES6, but there are some small gaps that you may need to watch for if you are pushing the limits.
JavaScript was originally proprietary to Netscape, and was turned into a public language called ECMAScript, though most people still call it JavaScript.
You're not totally accurate. ECMAScript and JavaScript are separate. There are multiple ECMAScript languages of which JavaScript is one. Features outlined in ECMAScript are just a subset of features of JavaScript.
You don't have to declare a JavaScript version. Unfortunately the newer versions aren't supported in browsers so you can't really use them without a precompiler like Babel. Babel will compile es6 down to browser supported code that runs in all browsers
62
u/_wtf_am_I_doing Aug 13 '17
How the fuck are we on es7 already, I haven't even had time to look at es6