ES6 Modules


To people new to Javascript, the whole ecosystem can seem a bit crazy because it is.

There's always been differences between the way different browsers implement the spec at any given time. There have always been things that don't work.

The way we do it now, all of the major browsers are considered 'evergreen' meaning that they'll never go out of date, as long as they keep connecting to the internet to get their updates.

What that means for Javascript is that eventually all of the features you've heard about will be implemented.

ES6 was a major revision of the language and you could easily argue that the 'community' should have paused for a few years to let everybody catch their breath and come up to speed, but they didn't.

In fact, before any of the major browsers had implemented the whole ES6 feature set, the standards committee (TC39) had begun the process of adding new features to the language.

To begin with, this was called ES2016, then maybe we would have ES2017 but... it became ridiculous to everyone, I guess, to be talking about the ES2016 specification, in 2017, knowing that ES2015 wasn't implemented in the browser. Eventually, the community accepted that the reality and the project is now referred to as ES Harmony - a rolling program of improvements.

ES6/2015 has been implemented somewhere - in Node.js for one, but long before that, it was already implemented in javascript 'transpilers' such as Babel.

Babel and other such transpilers can understand Javascript using the latest and greatest syntax from ES Harmony and produce plain old ES5, which is now guaranteed to work pretty much everywhere.

At first you might be perplexed as to how come they can make the 'old' javascript do all the things that the 'new' one can do but if you stop to think about it, we already know that any programming language can do everything.

The only thing that you can add to a programming language is 'syntactic sugar' since programming languages are 'pure sugar' to begin with.

The very simplest instruction in any programming language is 'just sugar' on top of something that the machine is actually doing.

When the language gets new features, then, they are just new ways of doing things. The sugar is important because it gives us new ways to express ourselves, which is really what the language is about.



Has been difficult:

12 Sep Node v8.5.0 (Current)

        Snapshots are now re-enabled in V8 #14875
        Implement minimal #14910
        upgrade libuv to 1.14.1 #14866
        update nghttp2 to v1.25.0 #14955
        Add verbatim option to dns.lookup(). When true, results from the DNS resolver are passed on as-is, without the reshuffling that Node.js otherwise does that puts IPv4 addresses before IPv6 addresses. #14731
        add fs.copyFile and fs.copyFileSync which allows for more efficient copying of files. #15034
        Enable async stack traces #13870
        Add support for ESM. This is currently behind the --experimental-modules flag and requires the .mjs extension. node --experimental-modules index.mjs #14369

Turns out they landed behind a flag in the stable release just 6 days ago and you need to change the file extension, invoking the Michael Jackson option.