UNPKG

3.28 kBMarkdownView Raw
1changequote([,])dnl
2# coffee-inline-map
3
4Compile 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
15include([a.coffee])
16$ coffee-inline-map a.coffee | fold -w72
17syscmd([../../../bin/coffee-inline-map a.coffee | fold -w72])
18
19$ coffee-inline-map -h
20syscmd([../../../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
33To verify the text below you'll need to clone this repo, run 'make
34compile' & install
35[[make-commonjs-depend]](https://github.com/gromnitsky/make-commonjs-depend).
36
37Look into repo's `test/data` directory. Ignore `*.should` files. I'll wait.
38
39Then
40
41```
42$ cd src
43$ ls *coffee
44syscmd([ls *coffee])
45```
46
47Here `main.coffee` depends on `a.coffee` & `b.litcoffee`. For out site
48we need just 1 `public/bundle.js` file which will include the result form the
49compilations of our all CoffeeScript files.
50
51We want to rebuild `public/bundle.js` only & only on .coffee files
52change. That's obviously a job for make.
53
54```
55$ cat Makefile
56include([Makefile])
57```
58
59To create a dependency tree, we run
60
61```
62$ make depend
63syscmd([make depend | egrep -v '(Entering|Leaving) directory'])
64```
65
66```
67$ cat js.mk
68include([js.mk])
69```
70
71It's unfortunate that make-commonjs-depend supports only
72javascript. That's why before running it, make needs to compile all
73coffescript files.
74
75Then compile the bundle
76
77```
78$ make compile
79syscmd([make compile | egrep -v '(Entering|Leaving) directory'])
80```
81
82As a little homework, try to guess why `main.js` was recompiled here,
83when at first glance it should rather not.
84
85Run again
86
87```
88$ make compile
89syscmd([make compile | egrep -v '(Entering|Leaving) directory'])
90```
91
92Notice that the nothing was recompiled for the 2nd time. That's our goal!
93
94```
95$ touch a.coffee
96$ make compile
97syscmd([touch a.coffee; make compile | egrep -v '(Entering|Leaving) directory'])
98```
99
100Yay! Then open `public/index.html` in Chrome and switch to the console
101view. (Make sure to turn on 'Enable source maps' in Developer Tool's
102settings.)
103
104## Jeez mate, why are you doing this rigmarole?
105
106Every dependency & every file should be compiled/processed only once.
107
108This seems meaningless for a bunch of small .coffee files but becomes
109very useful for large projects with several complex browserify output
110targets.
111
112## Why not just use coffeeify plugin for browserify?
113
1141. browserify can't (& shouldn't) check changes in our source files to
115 decide whether it's time to recompile.
1162. Error reporting.
117
118## Why are you using outdated make instead of cake, jake, grunt, gulp or broccoli? It's not 1977 anymore!
119
120facepalm.jpg
121
122Dude. <br/>
123Take 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
164MIT.