UNPKG

1.42 kBMarkdownView Raw
1# Espresso
2A quick shot of ES6 instead that old Coffee.
3
4This is a command line tool for converting CoffeeScript files into their ES6 equivalents*.
5
6*As close as possible, anyway.
7
8Available through NPM
9
10```bash
11npm install espresso-transformer
12```
13
14Using as CLI:
15Espresso will look for `.coffee` files if a directory is passed in as the first argument, and write the new `.es6` files to the same directory.
16
17(Given there is a directory called coffeescript)
18```bash
19espresso coffeescript/
20```
21
22To add the JSX transformer:
23
24```bash
25espresso coffeescript/ --jsx
26```
27
28To change which files to look for:
29
30```bash
31espresso coffeescript/ --match .coffeescript
32```
33
34To change the file type being written after transformation:
35
36```
37espresso coffeescript/ --extension .js
38```
39
40---
41
42## Transformers
43
44Core (default) transformer includes:
45- CommonJS `require`s -> ES2015 `import`s
46- CommonJS `module.exports` -> ES2015 `export default`
47- CoffeeScript fat arrow function => ES2015 fat arrow function
48- ES5 property function -> ES2015 object method
49
50JSX transformer includes:
51- React.DOM elements -> JSX element
52- React component factory -> JSX element
53- React.createElement -> JSX element
54
55Backbone Classes transformer:
56- converts Backbone Classes created with CoffeScript into their Backbone.Class.extend() equivalent
57
58
59## Up and Running (Development)
60After cloning this repo:
61
62```bash
63npm install
64npm link
65espresso --help
66```
67