ECMAScript 2016+ in Firefox
blog.mozilla.org
blog.mozilla.org
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?
Looking forward to the day alternative languages start targeting WebAssembly instead of JavaScript.
I just don't see what the point in having support for additional js language features natively is if you're forced to use a tranpiler regardless.
If you supported only, say, 50% of ES2016, and modules you could plausibly deliver unbundled native ES6; it'd be pretty cool; but modules aren't just a random feature from the pot; there is literally no serious modern web application that doesn't use them.
So... I'm struggling to see the ES2016 feature complete map (without modules) as really meaningful for anyone, practically.
https://hpbn.co/http2/#request-and-response-multiplexing
HTTP2 takes care of loading files via multiplexing, and ES6 modules take care of loading JS in proper order, no need to bundle AFAIU.
You can read more about why we'll always need a bundling step at the following links:
http://engineering.khanacademy.org/posts/js-packaging-http2....
https://medium.com/@asyncmax/the-right-way-to-bundle-your-as...
https://medium.com/webpack/webpack-http-2-7083ec3f3ce6#.74q6...
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.
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.
https://medium.com/the-node-js-collection/an-update-on-es6-m...
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.
Given the history of discussion around this, this seems surprisingly low key and reasonable. (The System.loader stuff was gnarly!)
But what does this mean for nodejs? I don't see how this rhymes with current proposals re `require.import` and the likes. If the above proposal wins out it becomes a language spec, so presumably will also become available in nodejs, and if they go ahead with the ideas mentioned in another comment here, we'd have both `import(specifier)` and `require.import(specifier)` – seems pretty confusing, but maybe I'm getting it all wrong?
<script type="module" src="main.js">
And then main.js runs in strict mode, can use "import", etc.
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.
- [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Modules and classes are always in strict mode. In practice, it really isn't an issue.
[1] https://www.nczonline.net/blog/2016/10/the-ecmascript-2016-c...
https://leanpub.com/understandinges6/read#leanpub-auto-chang...
If you have to execute code, things get messy.
(If so) CommonJS allows you to dynamically alter module.exports anywhere within your module. You can't determine what those exports are just by parsing, you'd need to execute the code.
It's certainly a risk, but that isn't a common practice.
if(Math.round(Math.random()) === 1) {
export let foo = bar; // have fun debugging!
}
I think it would also be fine to execute modules to see what's in module.exports, while some modules might have side effects like writing to /etc/passwd without calling any method, it's not the norm.(I assume you meant to write your example in CommonJS style, because that's not valid a ES6 export, they must be top-level).
Doesn't your example highlight exactly why even executing the code wouldn't even help you there?
You can't, at least not in this way. A module's imported and exported names are statically determined. Of course, you can just export a single object, and then make that object arbitrarily complex depending on runtime behavior.
> Like being able to require modules locally
Not sure what this means.
// 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
// ...
}Also, thrown in core-js[1] while you're at it.
Some of our projects are with customers that still rely on XP with IE 8, require using the "Internet Browser" for pre-Android 4.4 or Windows Safari (!) or IoT devices without updatable browsers.
Hopefully we have a better solution about making multiple bundles (separate one for IE) soon
It won't fix many issues (e.g. CSS), but at least some, and without making your build complicated, and without performance sacrifices for the majority of devices.
Many of them do care, but not the IT department that vets their machines.
I think it's (potentially) a better tradeoff than making most clients pay for larger bundle sizes even though they don't need it.
But well: tradeoffs.
I'd imagine that enterprises are still running many products with similar insane requirements, because they never get updates.
[0] http://www.vcaa.vic.edu.au/Pages/prep10/ondemand/index.aspx
https://www.howtogeek.com/184634/how-to-enable-and-use-inter...
Badly made software doesn't play ball.
Though it is theoretically possible to force it to work under IE8 mode, its simpler to supply real IE8 over a remote login.
Maybe the above table doesn't include beta releases of Chrome?
On the other hand, that's a poor excuse - why the heck haven't they fixed these issues? Cross browser compat is annoying enough as it is.
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.
Edit: and yes I know you were joking :)