How to: Migrate from CoffeeScript to ES6

It is quite easy to migrate from CoffeeScript to ES6. You can use decaffeinate Show archive.org snapshot to convert your CoffeeScript source to modern JavaScript.

Installation

  • Install the NPM module globally yarn global add decaffeinate
  • Add the following line to your ~/.bashrc to export the Yarn binaries in your Bash
export PATH="$PATH:$(yarn global bin)"
  • Run decaffeinate some.coffee to get the converted modern JavaScript file.

Notes

  • decaffeinate will add some suggestions Show archive.org snapshot to your newly generated JS file with advises that makes you JS cleaner. This action need to be done manually and carefully checked.
  • You might want to use the options Show archive.org snapshot --prefer-let and --use-js-modules
  • If you get errors while decaffeinating, try deleting your babel.config.js, run decaffeinate, restore the babel config file.
Emanuel Almost 5 years ago