Skip to content

Commit d34f18b

Browse files
committed
Update README.md
1 parent e2810cd commit d34f18b

File tree

1 file changed

+6
-248
lines changed

1 file changed

+6
-248
lines changed

README.md

Lines changed: 6 additions & 248 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# boot-cljs [![Circle CI](https://circleci.com/gh/adzerk-oss/boot-cljs.svg?style=shield)](https://circleci.com/gh/adzerk-oss/boot-cljs) [![Downloads](https://jarkeeper.com/adzerk/boot-cljs/downloads.svg)](https://jarkeeper.com/adzerk/boot-cljs) [![Dependencies Status](https://jarkeeper.com/adzerk/boot-cljs/status.svg)](https://jarkeeper.com/adzerk/boot-cljs)
22

3-
43
[](dependency)
54
```clojure
65
[adzerk/boot-cljs "1.7.170-3"] ;; latest release
@@ -14,19 +13,7 @@
1413
compiled in the same project.
1514
* **Related projects:** [boot-reload](https://github.com/adzerk-oss/boot-reload) and [boot-cljs-repl](https://github.com/adzerk-oss/boot-cljs-repl)
1615

17-
## Try It
18-
19-
In a terminal do:
20-
21-
```bash
22-
mkdir -p src/foop
23-
echo -e '(ns foop.core)\n(.log js/console "hello world")' > src/foop/core.cljs
24-
boot -s src -d adzerk/boot-cljs cljs
25-
```
26-
27-
The compiled JavaScript will be written to `target/main.js`.
28-
29-
## Usage
16+
## Quick start
3017

3118
Add ClojureScript and `boot-cljs` to your `build.boot` dependencies and `require` the namespace:
3219

@@ -38,240 +25,24 @@ Add ClojureScript and `boot-cljs` to your `build.boot` dependencies and `require
3825
You can see the options available on the command line:
3926

4027
```bash
41-
boot cljs -h
28+
boot cljs --help
4229
```
4330

44-
Or in the REPL:
31+
Or the same in the REPL:
4532

4633
```clj
4734
boot.user=> (doc cljs)
4835
```
4936

50-
You can see debug level output from the task by setting boot's logging level:
51-
52-
```bash
53-
boot -vv cljs
54-
```
55-
56-
This will show the options being passed to the CLJS compiler.
57-
58-
### Compilation Levels
59-
60-
The ClojureScript compiler uses the Google Closure compiler to generate
61-
optimized JavaScript when desired. There are [three different Closure
62-
compilation levels][closure-levels]: `whitespace`, `simple`, and
63-
`advanced`. You may specify the desired compilation level with the `-O`
64-
or `--optimizations` option:
65-
66-
```bash
67-
boot cljs -O advanced
68-
```
69-
70-
The default level is `none`, which bypasses the Closure compiler completely.
71-
This is handy for development work because it's very fast.
72-
73-
### Same HTML for Development and Production
74-
75-
The HTML file will always need to have a `<script>` tag to load the compiled
76-
JavaScript:
77-
78-
```html
79-
<script type='text/javascript' src='main.js'></script>
80-
```
81-
82-
### Source Maps
83-
84-
[Source maps][src-maps] associate locations in the compiled JavaScript file with
85-
the corresponding line and column in the ClojureScript source files. When source
86-
maps are enabled (the `-s` or `--source-map` option) the browser developer tools
87-
will refer to locations in the ClojureScript source rather than the compiled
88-
JavaScript.
89-
90-
```bash
91-
boot cljs -s
92-
```
93-
94-
> You may need to enable source maps in your browser's developer tools settings.
95-
96-
### Options
97-
98-
99-
| Option | Description | Task option | `.cljs.edn` |
100-
| --- | --- | --- | --- |
101-
| `optimizations` | `:none` (default), `:advanced` | × | |
102-
| `source-map` | Use source maps (default true for `:none` optimization) | × | |
103-
| `ids` | Selected `.cljs.edn` files | × | |
104-
| `require` | Namespaces to require on load | | × |
105-
| `init-fns` | Functions to call on load | | × |
106-
| `compiler-options` | Cljs compiler options | × | × |
107-
108-
109-
The `cljs` task normally does a good job of figuring out which options to pass
110-
to the compiler on its own. However, options can be provided via the `-c` or
111-
`--compiler-options` option, to provide [specific options to the CLJS compiler][cljs-opts]:
112-
113-
```bash
114-
boot cljs -c '{:target :nodejs}'
115-
```
116-
117-
### Incremental Builds
118-
119-
You can run boot such that it watches source files for changes and recompiles
120-
the JavaScript file as necessary:
121-
122-
```bash
123-
boot watch cljs
124-
```
125-
126-
You can also get audible notifications whenever the project is rebuilt:
127-
128-
```bash
129-
boot watch speak cljs
130-
```
131-
132-
> **Note:** The `watch` and `speak` tasks are not part of `boot-cljs`–they're
133-
> built-in tasks that come with boot.
134-
135-
### Multiple Builds
136-
137-
The `cljs` task provides a way to specify application entry points at which it
138-
can point the CLJS compiler for compilation. These entry points are provided
139-
via files with the `.cljs.edn` extension.
140-
141-
These files have the following structure (e.g. `js/index.cljs.edn`):
142-
143-
```clojure
144-
{:require [foo.bar baz.baf]
145-
:init-fns [foo.bar/init baz.baf/doit]
146-
:compiler-options {:target :nodejs}}
147-
```
148-
149-
For each `.cljs.edn` file in the fileset, the `cljs` task will:
150-
151-
* Create a CLJS namespace corresponding to the file's path, e.g. given the file
152-
`foo/bar.cljs.edn` it will create the `foo.bar` CLJS namespace. This namespace
153-
will `:require` any namespaces given in the `:require` key of the EDN, and
154-
add a `do` expression that calls any functions in `:init-fns` at the top
155-
level. These functions will be called with no arguments.
156-
157-
* Configure compiler options according to `:compiler-options` key of the EDN,
158-
if there is one.
159-
160-
* Configure the compiler to produce compiled JS at a location derived from the
161-
file's path, e.g. given the file `foo/bar.cljs.edn` the output JS file will
162-
be `foo/bar.js`.
163-
164-
* Point the CLJS compiler at the generated namespace only. This "scopes" the
165-
compiler to that namespace plus any transitive dependencies via `:require`.
166-
167-
The example above would result in the following CLJS namespace, `js/index.cljs`:
168-
169-
```clojure
170-
(ns js.index
171-
(:require foo.bar baz.baf))
172-
173-
(do (foo.bar/init)
174-
(baz.baf/doit))
175-
```
176-
177-
The result would be compiled to `js/index.js`. This is the JS script you'd add
178-
to the application's HTML file via a `<script>` tag.
179-
180-
### Preamble and Externs Files
181-
182-
Jars with `deps.cljs`, like the ones provided by [cljsjs][cljsjs] can
183-
be used to supply Javascript libraries. If you need to use local js files
184-
you can manually create deps.cljs in your local project:
185-
186-
src/deps.cljs:
187-
```clj
188-
{:foreign-libs [{:file "bar.js"
189-
:provides ["foo.bar"]}]
190-
:externs ["bar.ext.js"]}
191-
```
192-
193-
src/bar.js:
194-
```js
195-
function foo() {
196-
console.log("Hello world from local js");
197-
}
198-
```
199-
200-
src/bar.ext.js:
201-
```js
202-
foo = function() {};
203-
```
204-
205-
## Examples
206-
207-
Create a new ClojureScript project, like so:
208-
209-
```
210-
my-project
211-
├── build.boot
212-
├── html
213-
│   └── index.html
214-
└── src
215-
└── foop.cljs
216-
```
217-
218-
And add the following contents to `build.boot`:
219-
220-
```clj
221-
(set-env!
222-
:source-paths #{"src"}
223-
:resource-paths #{"html"}
224-
:dependencies '[[adzerk/boot-cljs "0.0-X-Y" :scope "test"]])
225-
226-
(require '[adzerk.boot-cljs :refer :all])
227-
```
228-
229-
Then in a terminal:
230-
231-
```bash
232-
boot cljs -s
233-
```
234-
235-
The compiled JavaScript file will be `target/main.js`.
236-
237-
Compile with advanced optimizations and source maps:
238-
239-
```bash
240-
boot cljs -sO advanced
241-
```
37+
For more [comprehesive guide](https://github.com/adzerk-oss/boot-cljs/wiki/Usage) check [wiki](https://github.com/adzerk-oss/boot-cljs/wiki).
24238

24339
### Further Reading
24440

245-
- For an example project with a local web server, CLJS REPL, and live-reload,
246-
check out [boot-cljs-example]!
41+
- [Simple example](https://github.com/adzerk-oss/boot-cljs/wiki/Example)
42+
- [boot-cljs-example](https://github.com/adzerk/boot-cljs-example) - An example project with a local web server, CLJS REPL, and live-reload.
24743
- [Saapas example project](https://github.com/Deraen/saapas)
24844
- [Tenzing project template](https://github.com/martinklepsch/tenzing)
24945

250-
## Hacking
251-
252-
To build the `boot-cljs` JAR and install to your local Maven repository:
253-
254-
```
255-
boot build-jar
256-
```
257-
258-
To run the tests:
259-
260-
```
261-
boot run-tests
262-
```
263-
264-
To deploy a snapshot to Clojars:
265-
266-
```
267-
boot build-jar push-snapshot
268-
```
269-
270-
To deploy a release to Clojars:
271-
272-
```
273-
boot build-jar push-release
274-
```
27546

27647
## License
27748

@@ -280,16 +51,3 @@ Copyright © 2015 Juho Teperi
28051

28152
Distributed under the Eclipse Public License either version 1.0 or (at
28253
your option) any later version.
283-
284-
[Boot]: https://github.com/boot-clj/boot
285-
[boot-clojars-latest]: http://clojars.org/adzerk/boot-cljs/latest-version.svg?cache=6
286-
[boot-clojars]: http://clojars.org/adzerk/boot-cljs
287-
[cider]: https://github.com/clojure-emacs/cider
288-
[boot-cljs-repl]: https://github.com/adzerk/boot-cljs-repl
289-
[src-maps]: https://developer.chrome.com/devtools/docs/javascript-debugging#source-maps
290-
[closure-compiler]: https://developers.google.com/closure/compiler/
291-
[closure-levels]: https://developers.google.com/closure/compiler/docs/compilation_levels
292-
[closure-externs]: https://developers.google.com/closure/compiler/docs/api-tutorial3#externs
293-
[boot-cljs-example]: https://github.com/adzerk/boot-cljs-example
294-
[cljs-opts]: https://github.com/clojure/clojurescript/wiki/Compiler-Options
295-
[cljsjs]: https://github.com/cljsjs/packages

0 commit comments

Comments
 (0)