• I want to write all my code in >ES6 (actually want to match what is implemented in Node 14 which is a good bit of ES8/2017 too). I am already using rollup but will need some transpilation. What is actually supported in Espruino 2.0+? I mean should I transpile/shim to ES5 or do I need to go older?

    Maybe if I knew exactly what was supported I could use buble to only transpile what is needed as in a espruino column like in this chart showing what is implemented. https://kangax.github.io/compat-table/es6/

  • check the open wishlist ES5/ES6 wishlist #1302 to have clear view what is available and what is missing.

  • There is page with ES compatibility here https://www.espruino.com/Features

    BTW sometimes this topic is started by people that are not fully aware that writing javascript for server or web browser running on machine with hundreds of megabytes or gigabytes of ram and writing javascript for microcontroller with e.g. 64 kilobytes may not be the same. There is not much memory available for bloated code and such tools may produce even more of it.

  • I understand the limitations. Mostly just need to to spin up a TCP socket client or server and manipulate the gpio bus. Sockets are supported in Espruino with the very similar to Node net library. This will be a simple refactor of my es6+ code written for node 14 (as long as I can transpile). By using my json packet command library (via the socket) I can offload any web UI and most other computation to a much more capable machine.

    Initially I figured on doing this all in CPP but the idea of basically have one code base for my json packet socket client/server is appealing. So even a little transpile bloat should be tolerable given I don't intend to run much code on esp32.

    Mostly just need a few things like class syntax and promises/async/await (to avoid callbacks), arrow funcs, let/const/scope and a few of the native object improvements. Rollup already handles esm to cjs.

  • Great. Would be nice to see practical example when such development flow works. Please share the results. I wonder how the source and the generated result will look like and how much of original code it handles before it hits some limits.

  • @fanoush thanks for the link. Surprisingly V2 seems to already support most of what I would need so maybe don't need to transpile or just use buble for the one off requirements like block scoping which I can't tell from table is supported. I will report back to this thread whatever I had to do and its impact.

  • Great! I'd be interested in how buble works. Block scoping isn't supported but is on my to-do list for Espruino so should arrive soon I hope

  • @Gordon, @fanoush

    I've put together a rollup starter repo with buble transforms for features not supported currently plus one pretty simple babal plugin for just async/await. Should work on any device (if you change the npm scripts). The starter currently runs a set of extended feature examples as a "test". With more work this could be made into something more generic which would allow noobs to get going faster with less pain. It will pretty much allow me to use my existing code es6/esm without too much modification nor too much transpiled bloat.

    It is structured so that a user works on app.js coding the app class therein for their particular application.

    Let me know if you successfully used it or what the issues are (can use github issue tracker). If the idea of a starter like this seems like a good idea then maybe others can help with improvements/upgrades.

    https://github.com/dkebler/espruino-starter.git

  • Nice - thanks! I'm a bit busy at the moment but I'll try and give it a look in the next week or so.

    This could end up being a nice way to also pull in typescript code I guess?

  • yes there is a rollup plugin for typescript so would be easy to add this.

    https://github.com/rollup/plugins/tree/master/packages/typescript

    Not sure if reducing to es6 and then following with what I have done (buble, etc) is best or just tell it to go all the way to es5. The later would include many superfluous transformations and defeat what I was trying to do which was only transform what was needed with buble and that single async/await.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

What JS release should I transpile to to support V2+ espruino

Posted by Avatar for dgk @dgk

Actions