1 | # exorcist [![build status](https://secure.travis-ci.org/thlorenz/exorcist.png)](http://travis-ci.org/thlorenz/exorcist)
|
2 |
|
3 | Externalizes the source map found inside a stream to an external `.js.map` file
|
4 |
|
5 | ```js
|
6 | var browserify = require('browserify')
|
7 | , path = require('path')
|
8 | , fs = require('fs')
|
9 | , exorcist = require('exorcist')
|
10 | , mapfile = path.join(__dirname, 'bundle.js.map')
|
11 |
|
12 | browserify()
|
13 | .require(require.resolve('./main'), { entry: true })
|
14 | .bundle({ debug: true })
|
15 | .pipe(exorcist(mapfile))
|
16 | .pipe(fs.createWriteStream(path.join(__dirname, 'bundle.js'), 'utf8'))
|
17 | ```
|
18 |
|
19 | ### command line example
|
20 |
|
21 | ```
|
22 | browserify main.js --debug | exorcist bundle.js.map > bundle.js
|
23 | ```
|
24 |
|
25 | ## Usage
|
26 |
|
27 | ```
|
28 | exorcist <mapfile> <exorcist-options>
|
29 |
|
30 | Externalizes the source map of a file that is streamed into it by pointing it's source map url to the <mapfile>.
|
31 | The original source map is written to the <mapfile> as json.
|
32 |
|
33 | OPTIONS:
|
34 |
|
35 | --root -r The path to the original source to be included in the source map. (default '')
|
36 | --url -u The path to the source map to which to point the sourceMappingURL. (default <mapfile>)
|
37 |
|
38 | EXAMPLE:
|
39 |
|
40 | Bundle main.js with browserify into bundle.js and externalize the map to bundle.js.map
|
41 |
|
42 | browserify main.js --debug | exorcist bundle.js.map > bundle.js
|
43 | ```
|
44 |
|
45 | ## Installation
|
46 |
|
47 | npm install exorcist
|
48 |
|
49 | ## API
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | <div>
|
56 | <div class="jsdoc-githubify">
|
57 | <section>
|
58 | <article>
|
59 | <div class="container-overview">
|
60 | <dl class="details">
|
61 | </dl>
|
62 | </div>
|
63 | <dl>
|
64 | <dt>
|
65 | <h4 class="name" id="exorcist"><span class="type-signature"></span>exorcist<span class="signature">(file, <span class="optional">url</span>, <span class="optional">root</span>)</span><span class="type-signature"> → {TransformStream}</span></h4>
|
66 | </dt>
|
67 | <dd>
|
68 | <div class="description">
|
69 | <p>Transforms the incoming stream of code by removing the inlined source map and writing it to an external map file.
|
70 | Additionally it adds a source map url that points to the extracted map file.</p>
|
71 | </div>
|
72 | <h5>Parameters:</h5>
|
73 | <table class="params">
|
74 | <thead>
|
75 | <tr>
|
76 | <th>Name</th>
|
77 | <th>Type</th>
|
78 | <th>Argument</th>
|
79 | <th class="last">Description</th>
|
80 | </tr>
|
81 | </thead>
|
82 | <tbody>
|
83 | <tr>
|
84 | <td class="name"><code>file</code></td>
|
85 | <td class="type">
|
86 | <span class="param-type">String</span>
|
87 | </td>
|
88 | <td class="attributes">
|
89 | </td>
|
90 | <td class="description last"><p>full path to the map file to which to write the extracted source map</p></td>
|
91 | </tr>
|
92 | <tr>
|
93 | <td class="name"><code>url</code></td>
|
94 | <td class="type">
|
95 | <span class="param-type">String</span>
|
96 | </td>
|
97 | <td class="attributes">
|
98 | <optional><br>
|
99 | </td>
|
100 | <td class="description last"><p>allows overriding the url at which the map file is found (default: name of map file)</p></td>
|
101 | </tr>
|
102 | <tr>
|
103 | <td class="name"><code>root</code></td>
|
104 | <td class="type">
|
105 | <span class="param-type">String</span>
|
106 | </td>
|
107 | <td class="attributes">
|
108 | <optional><br>
|
109 | </td>
|
110 | <td class="description last"><p>allows adjusting the source maps <code>sourceRoot</code> field (default: '')</p></td>
|
111 | </tr>
|
112 | </tbody>
|
113 | </table>
|
114 | <dl class="details">
|
115 | <dt class="tag-source">Source:</dt>
|
116 | <dd class="tag-source"><ul class="dummy">
|
117 | <li>
|
118 | <a href="https://github.com/thlorenz/exorcist/blob/master/index.js">index.js</a>
|
119 | <span>, </span>
|
120 | <a href="https://github.com/thlorenz/exorcist/blob/master/index.js#L27">lineno 27</a>
|
121 | </li>
|
122 | </ul></dd>
|
123 | </dl>
|
124 | <h5>Returns:</h5>
|
125 | <div class="param-desc">
|
126 | <p>transform stream into which to pipe the code containing the source map</p>
|
127 | </div>
|
128 | <dl>
|
129 | <dt>
|
130 | Type
|
131 | </dt>
|
132 | <dd>
|
133 | <span class="param-type">TransformStream</span>
|
134 | </dd>
|
135 | </dl>
|
136 | </dd>
|
137 | </dl>
|
138 | </article>
|
139 | </section>
|
140 | </div>
|
141 |
|
142 | *generated with [docme](https://github.com/thlorenz/docme)*
|
143 | </div>
|
144 |
|
145 |
|
146 | ## License
|
147 |
|
148 | MIT
|