binarynate/nativescript-utilities

ES6 -> ES5, Why

Closed this issue · 7 comments

I saw in your docs you are trans-piling it to ES5. Any specific reason you aren't just leaving it in ES6; the NativeScript engines should support ES6 natively on both platforms. ;-)

Hi, @NathanaelA . The project during which I created nativescript-utilities started out on version 2.3 of the NativeScript runtime, which didn't support ES 6. I recently saw that 2.4 was released, which adds support for ES 6. When I get the chance to, I'll update this and my other projects so that the ES 6 is imported directly. Once I do that and test to ensure importing and exporting works correctly, I'll bump the version number, update the npm package, and update this issue's status. The reason I call out importing and exporting specifically is that the babel-preset-node6 preset is still required in node to support the import and export keywords, and I'm not sure if NativeScript is the same way.

@binarynate - Ah, that makes sense. It is also possible about the "import" "export" words might not work. I haven't trying that in the runtimes yet. Hopefully they do. ;-)

@NathanaelA, just to follow up - I tested this with another package I'm preparing to publish and found that like Node 6, the NativeScript runtime doesn't support the import and export keywords yet. So, I'll either switch to the babel Node 6 preset so that only the import / export statements are transpiled or I'll swap the existing import / export statements for require / exports.

I just tried the Node 6 Babel preset with another project and found that the NativeScript runtime doesn't yet support the spread syntax yet either. I'm not sure if there are other features missing. For now, I'll stick with the current Babel preset.

Interesting I thought the Chrome v8 engine had full support for ES6. But looking into "import" "export" it does appear that nobody has implemented it yet...

Out of curiosity which runtime did you test spread syntax on? v8 is 5.2 so it should support spread syntax,

Thanks for mentioning that - I'm realizing now that I likely did not upgrade from 2.3 to 2.4 correctly. I had updated the versions of the platforms and tns-core-modules in my package.json to 2.4.0 and then deleted / reinstalled \node_modules and \platforms, but I didn't update my tns cli. I'm doing that now and will give the ES 6 another shot once I'm done.

Do a tns info, it will tell you what is outdated. Then if you want you can follow my blog article at http://fluentreports.com/blog on how to upgrade which ever piece(s) are outdated. ;-)