UNPKG

4.11 kBMarkdownView Raw
1# compiled
2> Compiles the ES* bundle to your NodeJS version on install
3
4[![NPM][compiled-icon] ][compiled-url]
5
6[![Build status][compiled-ci-image] ][compiled-ci-url]
7[![semantic-release][semantic-image] ][semantic-url]
8
9Read [JavaScript needs the compile step (on install)](http://glebbahmutov.com/blog/javascript-needs-compile-step/) blog post. If you want to precompile bundles instead of asking the client to do
10this, see [pre-compiled](https://github.com/bahmutov/pre-compiled).
11
12## Install and use
13
14 npm install -S compiled
15
16Add the configuration to your project's `package.json` file
17(I am assuming the root source file is `src/main.js`)
18
19```json
20"config": {
21 "compiled": {
22 "dir": "dist",
23 "files": ["src/main.js"]
24 }
25}
26```
27
28You can list multiple files in `files` list - each bundle will be processed separately.
29
30Define the following scripts in the `package.json`
31
32```json
33{
34 "scripts": {
35 "build": "build",
36 "postinstall": "compile"
37 },
38 "main": "dist/main.compiled.js"
39}
40```
41
42## Multiple bundles
43
44Good example is the [left-behind](https://github.com/bahmutov/left-behind) repo.
45It has the main code and a bin script. Each is compiled separately.
46
47## Force features
48
49You can force features to the list, maybe they are not detected by the feature tests.
50For example, to support the [new string repeat method](http://es6-features.org/#StringRepeating)
51
52```json
53"config": {
54 "compiled": {
55 "dir": "dist",
56 "files": ["src/main.js"],
57 "features": ["StringMethods"]
58 }
59}
60```
61
62Use the names returned by ES feature tests
63
64## Debug and development
65
66If you run this code using `DEBUG=compiled` variable, it will print debug log messages.
67For example
68
69 $ DEBUG=compiled npm run build
70 > compiled@0.0.0-semantic-release test-build /Users/kensho/git/compiled
71 > node bin/build.js src/main.js
72 compiled building from +0ms src/main.js
73 compiled saved bundle +69ms dist/bundle.js
74 compiled scanning for es features +39ms dist/bundle.js
75 compiled used ES features +15ms [ 'arrow', 'letConst', 'templateString' ]
76 compiled saved file with found es features +3ms dist/es6-features.json
77
78### Small print
79
80Author: Gleb Bahmutov © 2016
81
82* [@bahmutov](https://twitter.com/bahmutov)
83* [glebbahmutov.com](http://glebbahmutov.com)
84* [blog](http://glebbahmutov.com/blog/)
85
86License: MIT - do anything with the code, but don't blame me if it does not work.
87
88Spread the word: tweet, star on github, etc.
89
90Support: if you find any problems with this module, email / tweet /
91[open issue](https://github.com/bahmutov/compiled/issues) on Github
92
93## MIT License
94
95Copyright (c) 2016 Gleb Bahmutov
96
97Permission is hereby granted, free of charge, to any person
98obtaining a copy of this software and associated documentation
99files (the "Software"), to deal in the Software without
100restriction, including without limitation the rights to use,
101copy, modify, merge, publish, distribute, sublicense, and/or sell
102copies of the Software, and to permit persons to whom the
103Software is furnished to do so, subject to the following
104conditions:
105
106The above copyright notice and this permission notice shall be
107included in all copies or substantial portions of the Software.
108
109THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
110EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
111OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
112NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
113HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
114WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
115FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
116OTHER DEALINGS IN THE SOFTWARE.
117
118[compiled-icon]: https://nodei.co/npm/compiled.png?downloads=true
119[compiled-url]: https://npmjs.org/package/compiled
120[compiled-ci-image]: https://travis-ci.org/bahmutov/compiled.png?branch=master
121[compiled-ci-url]: https://travis-ci.org/bahmutov/compiled
122[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
123[semantic-url]: https://github.com/semantic-release/semantic-release
124