Realistically, when are we going to see the modules situation resolved?
ES2017?
ES2018?
I know, I know, just use a transpiler and emit a bundle... but really?
It's been a draft since 2015, and no browsers have any support for it yet, despite full support for the rest of the standard?
Are modules really that controversial?
I'm kind of disappointed, honestly, that despite all the progress in the ecosystem, this long standing issue still remains mysteriously unsolved, by anyone.
If you're using a transpiler anyway, who really cares if you have native support for the language features?
Note to people reading this: module support in this post seems to mostly refer to the loading of modules. The spec is pretty clear about the syntax and semantics of modules, except when it comes to loading which it more or less says is "up to the runtime" to figure out.
There's some interesting (or not, depending on your POV) conversation/debate going on between the nodejs world and the browser world, which are – I suppose – the only two "real" runtime environments where JS is widely used.
There's a lot of effort going into figuring this out, but from a lowly developer point of view it's increasingly frustrating to see that two years on from when the module standard was ratified, we still have to resort to compiling modules to a yesteryear solution such as AMD, CJS, or even globals – or, if you're so inclined, all at once via UMD.
One big issue in figuring this out, as far as I understand it, is determining whether some JS code is ES2015+ or not, since the semantics of loading such a module changes. It may sound simple, but there's plenty of situations where the answer is ambiguous, but picking the wrong answer will result in a change of behavior for older code. Since TC39 is very wary of not breaking backwards compatibility (and kudos to them for it!) simply saying something like "assume ES2015" just won't do.
There was a proposal to change the module semantics to require ES2015 modules to include at least one import or export statement, since these would break in pre-ES2015 runtimes, removing any ambiguity in the syntax. Unfortunately, it seems this proposal is all but dead at this point. (And probably for good reasons I simply don't know about.)
DISCLAIMER: I may well be incorrect about the details in the above, but I think the overall picture is more or less correct.
The purpose of Babel/transpilers is to eventually allow users to use the native versions of language features. Native support will eventually be faster (not at first), will result in less code sent to users (compiled code is larger), and easier to debug (don't need sourcemaps).
I made https://github.com/babel/babel-preset-env to make it easier to transition. Hoping that Babel makes it easier to not have to think about whether you are using native or not, so we'll work on that workflow.
Preliminary modules supports can be enabled in Firefox Nightly by changing dom.moduleScripts.enabled to true in about:config. There are still some bugs (https://bugzilla.mozilla.org/show_bug.cgi?id=568953) to fix before we can ship this.
JS modules are working in Safari Technology Preview today - so it should be available to everyone soon enough. Pretty simple too, you load your entry point like this -
<script type="module" src="main.js">
And then main.js runs in strict mode, can use "import", etc.
Even if the browsers support modules, you still will want to generate a bundle, because loading modules on the fly would require lots of tertiary HTTP requests.
If you're using a transpiler anyway, who really cares if you have native support for the language features?
I've been wondering the same thing. Surely the only exciting new language features are the ones that can't be polyfilled?
Native support means it can be smaller and faster, sure. But I don't think you can blame web bloat on Javascript's lack of built-in modules. Web bloat is caused by an arms race of advertising and tracking plugins. I don't care much about making those more efficient, I just want the advertising and tracking stripped out.
I wouldn't be surprised if a lot of the major players are holding back on JS modules until after WASM gets farther along.
It could seem like a waste of effort to standardize and implement JS modules (which "everyone already has" via transpilers) when they expect people to move quickly to language agnostic WASM modules once they become available.
my guess: to not complicate parsing complex expressions in default parameters
// non-strict mode top-level code
function foo (complex = eval("1+1"), moreComplex = (function(){ with (this) { return bar; } }())) {
"use strict"; // go back and parse the parameters again but this time with strict mode semantics
// ...
}
According to the documentation on MDN[0], it's a part of "early errors" and you should rather but the "use strict" outside the function instead of on the inside. I'm not entirely sure of why the spec wants it to be outside rather than inside though...
Good to see such quick progress in this area in major browsers. It's worth noting that WebKit also has 100% support for ES 2016+. So now only Edge is lagging in this regard.
I've always had a soft-spot for JavaScript, and have written a tonne of it over the years - all these "nice-to-haves" are really nice to have. I find it a lot more fun to write and, more importantly, easier to read six months later (assuming people don't try to be overly tricky with it: I'm looking at you, nested-destructed function parameters!)
Well, realistically, if you want an objectively better JS, use TS. It's completely opt-in, transpiles/compiles to JS, and you can finally maintain projects with more than 1 JS file in them, and no longer have to rage-delete the whole scripts.js file when - after adding the 66th god forsaken jQuery lib - something blows up the whole damn thing and all you're left with is a ridiculous error deep from within an unrelated library.
I think the Array.includes makes the language better as it standardizes how to check for array membership. I've encountered more than one bug as a result of the "!== -1" check not working correctly/as expected.
Not really, but there's certainly an off-by-one joke in there somewhere.
Since ES2015 the official nomenclature is ES<year>, to convey that a new version of the standard is cut yearly. While this may result in somewhat underwhelming releases, like ES2016, at least it's much easier to reason about and target than previously. Case in point, it took ten years or so to get from ES3 to ES5, and another five-six years I believe to get to ES2015.
These were substantial releases to be sure, but for a long time the uncertainty about when a spec draft was considered done was anything but fun, and I for one applaud the new nomenclature and process for being much, much easier to reason about and target.
[+] [-] shadowmint|9 years ago|reply
ES2017?
ES2018?
I know, I know, just use a transpiler and emit a bundle... but really?
It's been a draft since 2015, and no browsers have any support for it yet, despite full support for the rest of the standard?
Are modules really that controversial?
I'm kind of disappointed, honestly, that despite all the progress in the ecosystem, this long standing issue still remains mysteriously unsolved, by anyone.
If you're using a transpiler anyway, who really cares if you have native support for the language features?
[+] [-] mstade|9 years ago|reply
There's some interesting (or not, depending on your POV) conversation/debate going on between the nodejs world and the browser world, which are – I suppose – the only two "real" runtime environments where JS is widely used.
There's a lot of effort going into figuring this out, but from a lowly developer point of view it's increasingly frustrating to see that two years on from when the module standard was ratified, we still have to resort to compiling modules to a yesteryear solution such as AMD, CJS, or even globals – or, if you're so inclined, all at once via UMD.
One big issue in figuring this out, as far as I understand it, is determining whether some JS code is ES2015+ or not, since the semantics of loading such a module changes. It may sound simple, but there's plenty of situations where the answer is ambiguous, but picking the wrong answer will result in a change of behavior for older code. Since TC39 is very wary of not breaking backwards compatibility (and kudos to them for it!) simply saying something like "assume ES2015" just won't do.
There was a proposal to change the module semantics to require ES2015 modules to include at least one import or export statement, since these would break in pre-ES2015 runtimes, removing any ambiguity in the syntax. Unfortunately, it seems this proposal is all but dead at this point. (And probably for good reasons I simply don't know about.)
DISCLAIMER: I may well be incorrect about the details in the above, but I think the overall picture is more or less correct.
[+] [-] hzoo|9 years ago|reply
https://v8project.blogspot.com/2017/02/high-performance-es20...
I made https://github.com/babel/babel-preset-env to make it easier to transition. Hoping that Babel makes it easier to not have to think about whether you are using native or not, so we'll work on that workflow.
[+] [-] evilpie|9 years ago|reply
[+] [-] pjmlp|9 years ago|reply
Looking forward to the day alternative languages start targeting WebAssembly instead of JavaScript.
[+] [-] JoshGlazebrook|9 years ago|reply
https://medium.com/the-node-js-collection/an-update-on-es6-m...
[+] [-] chrisl99|9 years ago|reply
<script type="module" src="main.js">
And then main.js runs in strict mode, can use "import", etc.
[+] [-] moron4hire|9 years ago|reply
[+] [-] iainmerrick|9 years ago|reply
I've been wondering the same thing. Surely the only exciting new language features are the ones that can't be polyfilled?
Native support means it can be smaller and faster, sure. But I don't think you can blame web bloat on Javascript's lack of built-in modules. Web bloat is caused by an arms race of advertising and tracking plugins. I don't care much about making those more efficient, I just want the advertising and tracking stripped out.
[+] [-] Crespyl|9 years ago|reply
It could seem like a waste of effort to standardize and implement JS modules (which "everyone already has" via transpilers) when they expect people to move quickly to language agnostic WASM modules once they become available.
[+] [-] dotancohen|9 years ago|reply
[+] [-] z3t4|9 years ago|reply
[+] [-] nailer|9 years ago|reply
[+] [-] bushin|9 years ago|reply
https://leanpub.com/understandinges6/read#leanpub-auto-chang...
[+] [-] uwu|9 years ago|reply
[+] [-] swhipple|9 years ago|reply
[1] https://www.nczonline.net/blog/2016/10/the-ecmascript-2016-c...
[+] [-] kozak|9 years ago|reply
[+] [-] diggan|9 years ago|reply
- [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[+] [-] TheAceOfHearts|9 years ago|reply
[+] [-] cdnsteve|9 years ago|reply
[+] [-] M4v3R|9 years ago|reply
[0] http://kangax.github.io/compat-table/es2016plus/#webkit
[+] [-] whatever_dude|9 years ago|reply
http://kangax.github.io/compat-table/es5/
[+] [-] pjmlp|9 years ago|reply
[+] [-] krzyk|9 years ago|reply
Maybe the above table doesn't include beta releases of Chrome?
[+] [-] rocky1138|9 years ago|reply
[+] [-] mrspeaker|9 years ago|reply
[+] [-] pas|9 years ago|reply
[+] [-] dandersh|9 years ago|reply
[+] [-] dwaltrip|9 years ago|reply
[+] [-] hatsunearu|9 years ago|reply
[+] [-] scanr|9 years ago|reply
[+] [-] andrzejsz|9 years ago|reply
[+] [-] mstade|9 years ago|reply
Since ES2015 the official nomenclature is ES<year>, to convey that a new version of the standard is cut yearly. While this may result in somewhat underwhelming releases, like ES2016, at least it's much easier to reason about and target than previously. Case in point, it took ten years or so to get from ES3 to ES5, and another five-six years I believe to get to ES2015.
These were substantial releases to be sure, but for a long time the uncertainty about when a spec draft was considered done was anything but fun, and I for one applaud the new nomenclature and process for being much, much easier to reason about and target.
[+] [-] SimeVidas|9 years ago|reply
[+] [-] ihsw|9 years ago|reply
[deleted]