Twindle: Using ES6+ for nodejs

Created on 19 Oct 2020  路  8Comments  路  Source: twindle-co/twindle

I think we could use es6 syntax, by adding babel.
I know that it is complicated for beginners but the ones who are experienced with it could set it up for general use.
The es6 syntax is more readable I believe.
I have myself created a cli for these kind of things it could be used to initialize es6 projects :)
my cli -> link
I'm not trying to promote anything, just to be helpful for beginners 馃檪

Most helpful comment

In order to write es6 syntax such as import from etc, I would like to propose installing a npm package like esm. This takes care of converting from es6 to regular JS standard to run the scripts.

https://www.npmjs.com/package/esm.

Once it is installed and part of package.json, we can then use it as a script in package.json as:
"start": "node -r esm <file>.js"

All 8 comments

Why can't we simply write in ES6 format without the need for Babel? We should target new browsers [most now support ES6 - ECMA 2015 nowadays anyways].

I don't see the need for Babel here. Care to explain?

@tolgaerdonmez this is very helpful

Why can't we simply write in ES6 format without the need for Babel? We should target new browsers [most now support ES6 - ECMA 2015 nowadays anyways].

I don't see the need for Babel here. Care to explain?

As far as I know, nodejs doesnt support es6 format itself.

@tolgaerdonmez this is very helpful

thanks

@tolgaerdonmez Ah right! I totally forgot. My bad!

Why can't we simply write in ES6 format without the need for Babel? We should target new browsers [most now support ES6 - ECMA 2015 nowadays anyways].

I don't see the need for Babel here. Care to explain?

As far as I know, nodejs doesnt support es6 format itself.

Or supports as far as es8 minus the imports. Wet don't transpiler for node

In order to write es6 syntax such as import from etc, I would like to propose installing a npm package like esm. This takes care of converting from es6 to regular JS standard to run the scripts.

https://www.npmjs.com/package/esm.

Once it is installed and part of package.json, we can then use it as a script in package.json as:
"start": "node -r esm <file>.js"

@aravindsivasailam create a PR with a example and read me file.

Create a folder inside playground/cli

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnjacobkenny picture johnjacobkenny  路  4Comments

proful picture proful  路  5Comments

shekhar10feb picture shekhar10feb  路  3Comments

vasudeveloper001 picture vasudeveloper001  路  4Comments

piratelicorne picture piratelicorne  路  7Comments