1 | changequote([,])dnl
|
2 | # coffee-inline-map
|
3 |
|
4 | Compile CoffeeScript files with inline source maps.
|
5 |
|
6 | ## Features
|
7 |
|
8 | * Error reporting similar to the original CoffeeScript compiler.
|
9 | * `.litcoffee` support.
|
10 |
|
11 | ## Example
|
12 |
|
13 | ```
|
14 | $ cat a.coffee
|
15 | include([a.coffee])
|
16 | $ coffee-inline-map a.coffee | fold -w72
|
17 | syscmd([../../../bin/coffee-inline-map a.coffee | fold -w72])
|
18 |
|
19 | $ coffee-inline-map -h
|
20 | syscmd([../../../bin/coffee-inline-map -h])
|
21 | ```
|
22 |
|
23 | ## Installation
|
24 |
|
25 | # npm install -g coffee-inline-map
|
26 |
|
27 | ## Compilation
|
28 |
|
29 | $ make compile
|
30 |
|
31 | ## browserify & make-commonjs-depend
|
32 |
|
33 | To verify the text below you'll need to clone this repo, run 'make
|
34 | compile' & install
|
35 | [[make-commonjs-depend]](https://github.com/gromnitsky/make-commonjs-depend).
|
36 |
|
37 | Look into repo's `test/data` directory. Ignore `*.should` files. I'll wait.
|
38 |
|
39 | Then
|
40 |
|
41 | ```
|
42 | $ cd src
|
43 | $ ls *coffee
|
44 | syscmd([ls *coffee])
|
45 | ```
|
46 |
|
47 | Here `main.coffee` depends on `a.coffee` & `b.litcoffee`. For out site
|
48 | we need just 1 `public/bundle.js` file which will include the result form the
|
49 | compilations of our all CoffeeScript files.
|
50 |
|
51 | We want to rebuild `public/bundle.js` only & only on .coffee files
|
52 | change. That's obviously a job for make.
|
53 |
|
54 | ```
|
55 | $ cat Makefile
|
56 | include([Makefile])
|
57 | ```
|
58 |
|
59 | To create a dependency tree, we run
|
60 |
|
61 | ```
|
62 | $ make depend
|
63 | syscmd([make depend | egrep -v '(Entering|Leaving) directory'])
|
64 | ```
|
65 |
|
66 | ```
|
67 | $ cat js.mk
|
68 | include([js.mk])
|
69 | ```
|
70 |
|
71 | It's unfortunate that make-commonjs-depend supports only
|
72 | javascript. That's why before running it, make needs to compile all
|
73 | coffescript files.
|
74 |
|
75 | Then compile the bundle
|
76 |
|
77 | ```
|
78 | $ make compile
|
79 | syscmd([make compile | egrep -v '(Entering|Leaving) directory'])
|
80 | ```
|
81 |
|
82 | As a little homework, try to guess why `main.js` was recompiled here,
|
83 | when at first glance it should rather not.
|
84 |
|
85 | Run again
|
86 |
|
87 | ```
|
88 | $ make compile
|
89 | syscmd([make compile | egrep -v '(Entering|Leaving) directory'])
|
90 | ```
|
91 |
|
92 | Notice that the nothing was recompiled for the 2nd time. That's our goal!
|
93 |
|
94 | ```
|
95 | $ touch a.coffee
|
96 | $ make compile
|
97 | syscmd([touch a.coffee; make compile | egrep -v '(Entering|Leaving) directory'])
|
98 | ```
|
99 |
|
100 | Yay! Then open `public/index.html` in Chrome and switch to the console
|
101 | view. (Make sure to turn on 'Enable source maps' in Developer Tool's
|
102 | settings.)
|
103 |
|
104 | ## Jeez mate, why are you doing this rigmarole?
|
105 |
|
106 | Every dependency & every file should be compiled/processed only once.
|
107 |
|
108 | This seems meaningless for a bunch of small .coffee files but becomes
|
109 | very useful for large projects with several complex browserify output
|
110 | targets.
|
111 |
|
112 | ## Why not just use coffeeify plugin for browserify?
|
113 |
|
114 | 1. browserify can't (& shouldn't) check changes in our source files to
|
115 | decide whether it's time to recompile.
|
116 | 2. Error reporting.
|
117 |
|
118 | ## Why are you using outdated make instead of cake, jake, grunt, gulp or broccoli? It's not 1977 anymore!
|
119 |
|
120 | facepalm.jpg
|
121 |
|
122 | Dude. <br/>
|
123 | Take a walk for 10 minutes & no one will get hurt.
|
124 |
|
125 | ## BUGS
|
126 |
|
127 | * Reading from stdin doesn't work in Windows.
|
128 |
|
129 | ## NEWS
|
130 |
|
131 | ### 0.9.0
|
132 |
|
133 | * CoffeeScript 1.10.0.
|
134 |
|
135 | ### ...
|
136 |
|
137 | ### 0.5.0
|
138 |
|
139 | * CoffeeScript 1.8.0.
|
140 |
|
141 | ### 0.4.0
|
142 |
|
143 | * CoffeeScript 1.7.1
|
144 | * 'New' source map syntax.
|
145 |
|
146 | ### 0.3.0
|
147 |
|
148 | * `-b` CLO.
|
149 | * Include 'generated by ...' header.
|
150 |
|
151 | ### 0.2.0
|
152 |
|
153 | * Update for CoffeeScript 1.6.3.
|
154 | * Recognize `.coffee.md` extension.
|
155 | * `-l` CLO.
|
156 |
|
157 | ### 0.1.0
|
158 |
|
159 | * Add reading from stdin.
|
160 | * Fix an unheplful crash for EPIPE error.
|
161 |
|
162 | ## License
|
163 |
|
164 | MIT.
|