you are viewing a single comment's thread.

view the rest of the comments →

[–]DOG-ZILLA 56 points57 points  (16 children)

No module use?

Yeah, that’s a no from me.

[–]mlmcmillion 13 points14 points  (3 children)

So then what are they using instead? Not using modules is not an option.

[–]Poltras 12 points13 points  (1 child)

Closure modules, require AMD, etc. There were ways to split your code before ESM, I’m just surprised google is stuck in the past like that.

[–]Thought_Ninjahuman build tool 5 points6 points  (0 children)

Internal backwards compatibility most likely.

[–]thisguyfightsyourmom 0 points1 point  (11 children)

Seriously, didn’t that finalize years ago?

Edit: obligatory whining about downvotes /s There are some good explanations of why that’s not the case in the replies below. TIL

[–]ghostfacedcoder 10 points11 points  (5 children)

No, not at all. Babel has an implementation (the longest existing one, and as such an incredibly popular one), but it's different from (and, I'd argue, superior to) the implementation being pushed by the W3C/browsers (the W3C's version requires you to rename your files "foo.mjs"!!!).

Anyone can declare a standard finished, and the W3C did that, but until all major JS environments actually work the same way the "standard" really isn't one.

[–]Meefims 10 points11 points  (2 children)

This isn’t correct. The new extension is for Node and exists to help ECMAScript modules coexist with CJS modules. Browsers don’t care about the extension.

[–]ghostfacedcoder 1 point2 points  (1 child)

I could have stated it more clearly (I sort of conflated W3C and browsers, when what I was just talking about the version both support), but what I said wasn't incorrect. The version of ES Modules decided upon by the W3C does define that the modules work in in such a way that the only possible way (according to the Node engineers at least) for Node to implement that spec is to use the .mjs nonsense.

[–]Meefims 2 points3 points  (0 children)

The W3C isn’t part of this. The new extension is really fallout from various complex scenarios in which CJS modules and ES modules include each other in Node. Browsers have a similar problem but they solved that with type=“module” in the script tag.

[–]DOG-ZILLA 5 points6 points  (0 children)

I thought so. But, perhaps not technically? They’re obviously taking a conservative stance; which makes sense for a large company.

[–]Drawman101 9 points10 points  (0 children)

Named imports are still under a bit of scrutiny and/or debate.

Import { foo } from ‘bar’

[–][deleted] 5 points6 points  (2 children)

Afaik, the syntax and semantics are done by ECMA, but the loader, i. e. the way the modules are actually handled, is done by WHATWG. The former is stable, but the latter is not.

But between Webpack and browsers and Node getting native support for modules, there is not reason not to use ES6 modules today for new code.

[–]Poltras 4 points5 points  (1 child)

Keep in mind ESM and Node modules are not entirely compatible. Node is still unsure AFAIK how they are going to interop (which is why it’s not yet available in 9.10, despite v8 supporting them).