coffee-babel
v1.0.5
Published
A simple wrapper around coffeescript/register to allow parameters to be passed to coffeescript.
Downloads
6
Readme
coffee-babel [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]
This is a node application generated using generator-coffee-node.
This package came about as an attempt to improve on the default coffeescript/register
method of importing .coffee files. Currently there is no way to pass options. This wrapper does that for you.
This wouldn't be possible without this post. The primary code is a copy-paste of his code with a few tweaks - many thanks to him.
By default this package uses v2.2.4 of coffeescript. Any modern version of node should use whatever you are using though.
Usage
First install the package using yarn or npm:
yarn add --dev coffee-babel
Then you can require the file before any coffeescript.
require('coffee-babel')({ // This is the default behavior
transpile: {
presets: [ 'env' ]
}
})
module.exports = require('myfile.coffee'); // file is transpiled.
You can even change the behavior of the compiler by calling the required function again.
coffeeConfig = require('coffee-babel');
coffeeConfig() // removes the default config
require('myOldES5File.coffee');
coffeeConfig({
transpile: {
presets: [ 'env' ]
}
})
require('myNewES6File.coffee');