Opinion: Maidsafe Node modules should be es2015 by default, developers shouldn't be responsible for compilation

This post relates to the Safe-app-nodeJS library and the code which it exports. Let me preface this by saying that I think the module is fantastic, what it provides (once you can get over the painful step of actually getting it set up in your local environment) is an invaluable resource for SafeNet app development.

With that being said:

If you’re going to publish a module which essentially requires Electron (or some other full application lifecycle tool) you should adhere to the minimum provided language support of those tools - or to put it plainly: if Electron doesn’t support ES2017 by default, the code you publish shouldn’t be ES2017.

By using the following ES2017 await example here - obviously, there are a tonne more examples - you make compiling the Maidsafe JS code using Babel a requirement for all consumers of your API - which is frankly unreasonable.

It’s fine to write code in ES2017 - I understand why the apps have been built in this way - but when they’re published you should be compiling them using babel’s prepublish command.

1 Like

Hi Shane,

I just realised that I’ve never used safe_app_nodejs without electron.

Are you having trouble with ES2017 features while using electron or just without?

Which version of Node.js are you running?

I’m curious now to know why I haven’t had to transpile from ES2017, https://github.com/hunterlester/safe-app-base.

Does electron automatically transpile based on Node version in use? I’ll have to experiment and read up over the next week to learn more about this.

1 Like

Hey Shane

The async command (along with other ES2017 features) should work in electron and nodejs by default unless you’re using a really old version? You shouldn’t need to use babel at all for any of this, even for electron.

I would say we shouldn’t be adding babel compiled code to our repositories if the latest stable versions of node and electron work out of the box.

I’ll give it a go myself too and see if I can recreate your issue.

EDIT: Yeah I can confirm everything works out of the box using:


Electron: v1.7.11
NodeJS: v8.9.4

3 Likes