Port to ES2015
See original GitHub issueThis is sort of a long term maybe-nice-to-have goal for the JS implementation of RiveScript: rewrite the source code in EcmaScript 2015 (ES6).
There’s this gist about migrating from CoffeeScript to ES6 which contains a nice overview of the new ES6 syntax and how it compares to CoffeeScript syntax.
A script like decaffeinate may help, if it produces high enough quality code. Otherwise a manual rewrite would produce better code.
There’s also this article Don’t Replace CoffeeScript with ES6 Transpilers, but most of its points are mostly only true of web browsers. Node supports ES6 so developers of Node apps could use the RiveScript-ES6 modules directly (no grunt build
step needed to transpile from CS to JS), which also brings the benefit of Node devs being able to git clone
this repo and use it immediately. But I’d have to investigate whether or not to support older versions of Node (if they can’t just npm install
it and get the raw ES6 code to work, that may be a reason not to move away from grunt
to transpile code into ES5 syntax and therefore we can just stay on CoffeeScript).
For web browsers, there’s already the required CoffeeScript+browserify steps to create a JS file suitable for the web, so replacing it with Babel isn’t much different.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:9 (7 by maintainers)
Top GitHub Comments
you could also use Typescript to get typechecking and async/await is there right now. It will compile down to ES5 for browsers (tho not if you use await/async). I’m using that for current projects. If the goal is to keep things as simple as possible for more contributors, probably not a good idea, but if you want to have more powerful tooling but with a bit of setup overhead, then it’s a good option IMHO.
There’s also livescript which has a nice pipe syntax
|>
(like Elixir) that maybe good for these type of scripts where you’re piping inputs around… but fairly niche tool.Don’t forget about WebPack, it will help a lot people that uses WebPack, if you managed to full convert, I can write a .rive loader for WebPack.