Guidance on use of ES6 in Nodes

393 views
Skip to first unread message

Giles Roadnight

unread,
Jun 7, 2016, 4:11:48 AM6/7/16
to Node-RED
Hi All

I'm developing some nodes at the moment and working on a new Raspberry Pi 3 that I have not upraded Node on yet. This means that none of the ES6 features (like arrow functions) work so I've had to resort to basic javascript!

Is there any best practice advice on weather we can use these features or not? If I do use them then obviously anyone who uses my node has to upgrade Node.

Do all version of Node-Red work on all versions of Node? My node will need Node-red version 0.14.0 so if that requires a new version of Node then I'll be safe using these new features.

Thanks
Giles

Dave C-J

unread,
Jun 7, 2016, 5:10:35 AM6/7/16
to node...@googlegroups.com
sorry...:-)  but 0.14.0 will still run on default v0.10.29 node.js as comes with Debian etc on Pi... so it's up to you if you want to target ES6 and newer version of node.

Julian Knight

unread,
Jun 7, 2016, 6:28:46 AM6/7/16
to Node-RED, gi...@roadnight.name
The current sweet spot seems to be Node.JS v4 which is the recommended version. This only supports a limited set of new JS features. you can use things like let and const for example.

However, I'm not sure how much the function node's editor has been updated. So you may get warnings from it.

To go further, if you are developing your own nodes, I guess you could use Babel but that seems to be adding complexity for relatively little gain (unless perhaps you are developing a really complex node).

It would be great to see the function node editor with some additional options including recognition of more ES6 and alternative JS styling. For example, I find it vastly preferable to write with a no semi-colon style but the editor always complains :(

Giles Roadnight

unread,
Jun 7, 2016, 8:57:19 AM6/7/16
to Julian Knight, Node-RED

OK, so I can use it if I like but not if I want everyone to be able to use my node!
It's not complex so I can live with ES5, would just prefer to use newer features.

Thanks ms fir the replies.

Luis Montes

unread,
Jun 7, 2016, 9:04:07 AM6/7/16
to node...@googlegroups.com, Julian Knight
You can write in whatever you want just make sure to transpile it to ES5 before you publish it to npm if you want other people to use it.

I've been using babeljs for this and it works great.


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Giles Roadnight

unread,
Jun 7, 2016, 9:13:44 AM6/7/16
to node...@googlegroups.com, Julian Knight

I use Typescript but for this amount of code it's not worth it.

Reply all
Reply to author
Forward
0 new messages