1 | # Espresso
|
2 | A quick shot of ES6 instead that old Coffee.
|
3 |
|
4 | This is a command line tool for converting CoffeeScript files into their ES6 equivalents*.
|
5 |
|
6 | *As close as possible, anyway.
|
7 |
|
8 | Available through NPM
|
9 |
|
10 | ```bash
|
11 | npm install espresso-transformer
|
12 | ```
|
13 |
|
14 | Using as CLI:
|
15 | Espresso 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
|
19 | espresso coffeescript/
|
20 | ```
|
21 |
|
22 | To add the JSX transformer:
|
23 |
|
24 | ```bash
|
25 | espresso coffeescript/ --jsx
|
26 | ```
|
27 |
|
28 | To change which files to look for:
|
29 |
|
30 | ```bash
|
31 | espresso coffeescript/ --match .coffeescript
|
32 | ```
|
33 |
|
34 | To change the file type being written after transformation:
|
35 |
|
36 | ```
|
37 | espresso coffeescript/ --extension .js
|
38 | ```
|
39 |
|
40 | ---
|
41 |
|
42 | ## Transformers
|
43 |
|
44 | Core (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 |
|
50 | JSX transformer includes:
|
51 | - React.DOM elements -> JSX element
|
52 | - React component factory -> JSX element
|
53 | - React.createElement -> JSX element
|
54 |
|
55 | Backbone Classes transformer:
|
56 | - converts Backbone Classes created with CoffeScript into their Backbone.Class.extend() equivalent
|
57 |
|
58 |
|
59 | ## Up and Running (Development)
|
60 | After cloning this repo:
|
61 |
|
62 | ```bash
|
63 | npm install
|
64 | npm link
|
65 | espresso --help
|
66 | ```
|
67 |
|