r/javascript • • Apr 21 '20

Node.js v14 released

https://medium.com/@nodejs/node-js-version-14-available-now-8170d384567e
419 Upvotes

74 comments sorted by

View all comments

140

u/mastermind202 Apr 21 '20

Looks like we finally get optional chaining and null coalescing!

0

u/[deleted] Apr 21 '20

[deleted]

29

u/[deleted] Apr 21 '20

I wish that's true but Node native ESM import has some subtle differences compare to Babel's implementation.

51

u/lhorie Apr 21 '20

Switch over to native ESM and you'll quickly find out what babel bugs you were relying on #move-fast-break-things

3

u/lulzmachine Apr 22 '20

Native ESM import is is sure way to make anybody using windows unhappy. And oh you want to be able clear something from the import cache and reload? Naaah... just naaaah.

2

u/schlenkster Apr 22 '20

I’m not sure if you can clear it, but you can import it again with a query string appended to get a fresh copy.

→ More replies (2)

0

u/[deleted] Apr 22 '20

[deleted]

→ More replies (1)

2

u/McThakken Apr 21 '20

Why? šŸ™ˆšŸ¤”

37

u/evilgwyn Apr 21 '20

Removing babel makes the none_modules folder smaller by about 50MB

12

u/calligraphic-io Apr 21 '20

Because none_modules is then an empty directory? :)

0

u/[deleted] Apr 21 '20

[deleted]

→ More replies (3)

9

u/ShortFuse Apr 21 '20

Babel will transcompile (downconvert) the ES2020 syntax code to something Node can understand (eg: CommonJS+ES2015).

See https://node.green/ to see what version of NodeJS support what syntax.

6

u/[deleted] Apr 21 '20

[removed] — view removed comment

→ More replies (2)

41

u/JonathanTheZero Apr 21 '20

laughs in TypeScript

12

u/ShortFuse Apr 21 '20

Well, if you're going to transcompile your code than of course you can use any syntax your want. You can use Babel and accomplish the same.

7

u/forsubbingonly Apr 21 '20 edited Apr 21 '20

Imagine transpiling your code from JavaScript to JavaScript lol

2

u/NeverMakesMistkes Apr 22 '20

Lots of people also use Babel to compile TS to JS. It can be quite a bit faster if you just need the compilation and do type checking separately.

10

u/LetterBoxSnatch Apr 22 '20

Pendant: Babel doesn't compile TS to JS, it merely strips out the TS. That's why it's faster.

4

u/wetapotatoworkshop Apr 22 '20

I hope I caught you spelling "pedant" (overly teachy) as "pendant" (necklace thing)!

→ More replies (3)

2

u/lesleh Apr 22 '20

What does it do with code like this then? Just removing the types would change the semantics of the code.

class Foo {
    constructor(public bar: string) { }
}

2

u/csorfab Apr 22 '20

in what way would it change the semantics?

→ More replies (2)

14

u/aurbano Apr 21 '20

Huh TIL that I had been using optional chaining thanks to the TypeScript suggestions in vs code without realising it was thanks to the ts compiler :)

→ More replies (1)