In order to use export / import in a Node.JS, we need either Babel or another third-party library, since ES6 modules are not supported natively. But why then can we use async / await, spread, rest without Babel? After all, all above mentioned have appeared since the ES6 syntax
Asked
Active
Viewed 28 times
1
-
Yes you can. The things that you've listed are natively supported in ES6. – Terry Sep 01 '20 at 16:52
-
1ES modules are supported natively now: https://nodejs.org/api/esm.html . It took a while to support it simply because it was a complex thing to get right. Unlike the other features you mentioned, ES modules are kind of conflict with the existing module system, CommonJS. So a main question was how interoperability between CommonJS and ES modules should work. – Felix Kling Sep 01 '20 at 17:42
-
1@Terry: FWIW, async/await is part of ES2017, not ES6. – Felix Kling Sep 01 '20 at 17:43