boot-figwheel icon indicating copy to clipboard operation
boot-figwheel copied to clipboard

Boot repl interface interacting a Figwheel system for ClojureScript development.

#+STARTUP: content #+TITLE: boot-figwheel #+AUTHOR: aJchemist #+UPDATE: Sun Apr 10 09:33:46 2016 #+LINK: Boot https://github.com/boot-clj/boot #+LINK: boot-cljs-repl https://github.com/adzerk-oss/boot-cljs-repl #+LINK: Figwheel https://github.com/bhauman/lein-figwheel

[[https://clojars.org/ajchemist/boot-figwheel][https://img.shields.io/clojars/v/ajchemist/boot-figwheel.svg]] [[https://circleci.com/gh/aJchemist/boot-figwheel][https://circleci.com/gh/aJchemist/boot-figwheel.svg?style=shield]] [[https://github.com/aJchemist/cljs-devtools-sample/blob/master/build.boot][https://img.shields.io/badge/example-build.boot-ff69b4.svg]]

[[Figwheel]] interface for [[Boot]] repl.

boot-figwheel currently intend to provide same api that exist in [[https://github.com/bhauman/lein-figwheel/blob/master/sidecar/src/figwheel_sidecar/repl_api.clj][figwheel-sidecar.repl-api]].

** Dependencies

#+begin_src clojure [ajchemist/boot-figwheel "0.5.4-6"] ;; latest release [org.clojure/tools.nrepl "0.2.12" :scope "test"] [com.cemerick/piggieback "0.2.1" :scope "test"] [figwheel-sidecar "0.5.7" :scope "test"] #+end_src

figwheel-sidecar whose version is above =0.5.x= would be well accepted.

NOTE: After version 0.5.0, boot-figwheel changed how the REPL dependencies are handled. For now user is required to add dependencies to one's project which are necessary libraries. =figwheel= task will print the required dependecies when run. This change related to [[https://github.com/adzerk-oss/boot-cljs-repl/commit/e05d587240a46067633362f8aa0164ea8ed61f52][this]].

** Usage

#+name: require #+begin_src clojure (require 'boot-figwheel) (refer 'boot-figwheel :rename '{cljs-repl fw-cljs-repl}) ; avoid some symbols #+end_src

#+begin_src clojure (task-options! figwheel {:build-ids ["dev"] :all-builds [{:id "dev" :source-paths ["src"] ; cljs(cljc) directories :compiler {:main 'app.core :output-to "app.js"} :figwheel {:build-id "dev" :on-jsload 'app.core/main :heads-up-display true :autoload true :debug false}}] :figwheel-options {:open-file-command "emacsclient" :repl true}}) #+end_src

When users need to change their cljsbuild config on live, just eval =(task-options! :figwheel {...})= at the time, and restart the figwheel.

If a user doesn't supply =build-ids= options, figwheel-system will build all build configurations.

Now start a boot repl.

: boot figwheel repl

=figwheel= task updates =:output-to= compiler option so that the build output locate in =:target-path= (default is "target").

After the repl is started, ordinary dev routines follow. #+begin_src clojure boot.user> (start-figwheel!) boot.user> (start-autobuild) boot.user> (stop-autobuild) boot.user> (fw-cljs-repl) cljs.core> (fig-status) cljs.core> :cljs/quit ... boot.user> (task-options! :figwheel {...}) ... boot.user> (stop-figwheel!) boot.user> (start-figwheel!) #+end_src

when =(fw-cljs-repl)= is an issue, then see [[https://github.com/aJchemist/boot-figwheel/issues/7][#7]].

** Other examples

  • [[https://github.com/aJchemist/cljs-devtools-sample/blob/master/build.boot][cljs-devtools-sample]] project

try with

: boot demo

or

: boot demo-figwheel repl

  • [[https://github.com/aJchemist/rum-mdl/blob/master/build.boot][rum-mdl]] project

** Change

*** 0.5.4-6

  • When =:optimizations= is not =:none=, then =:output-dir= will not be configured by default.

*** 0.5.4-5

  • Separate =figwheel= task into two parts, one is a preamble and another is a middleware.

*** 0.5.4-4

  • [ BREAKING ] Integrate =boot-figwheel= and =fw-build-once= task functionalities into =figwheel= task.
  • Add a new =figwheel= task-option, called =once-ids= to specify configurations which are going to be built once.

So now, please change following composed task

#+begin_src clojure (comp (figwheel) (boot-figwheel :ids ["main"]) (fw-build-once :ids ["advanced"])) #+end_src

to this oneliner

#+begin_src clojure (figwheel :build-ids ["main"] :once-ids ["advanced"]) #+end_src

*** 0.5.4-3

  • [ BREAKING ] Now users should configure their =:source-paths= in =:all-builds= task option. =(get-env :source-paths)= is no longer injected into user build configurations =:source-paths=.
  • Add new =boot-figwheel= task to run figwheel-system. Users can apply this task to cljs building on startup time.
  • Add new =fw-build-once= task to build supplied ids once. Users can also apply this task on startup time.

#+begin_src clojure (comp (figwheel) (boot-figwheel :ids ["main"]) ; -> "advanced" configuration is out of autobuilder (fw-build-once :ids ["advanced"])) #+end_src

  • =[:figwheel-options :css-dirs]= should have explicit configuration if a user want to figwheel css watcher feature.

*** 0.5.4

=figwheel= has now new task-option =target-path= for specifying explicit target-path.

And when

  • =[:figwheel-options :http-server-root]=
  • =[:figwheel-options :css-dirs]=

are not specifed, boot-figwheel uses ="target"= for those.

NOTE: [[Boot]] has recently had built-in =target= task for explicit emitting target, so now boot-figwheel can be cooperated with built-in =watch= task with =(target :no-clean true)=. [[https://github.com/aJchemist/boot-figwheel/issues/4][#4]]

*** 0.5.0-2

  • Both =:output-to= and =:output-dir= would be prefixed with =:target-path= whether they are specified or not.
  • Parent of =:output-dir= would be the same as the parent of =:output-to= unless =:output-dir= is specifed.
  • =:asset-path= would be prefixed with =:target-path= only if it's not specified. (thx [[https://github.com/kalouantonis][Antonis Kalou]] PR #2)

*** 0.5.0

  • [ BREAKING ] Figwheel has changed a lot since =0.5.0= release. So boot-figwheel have had to adapt to it. Now boot-figwheel doesn't make another pod for =figwheel= and =figwheel= runs on the same pod where your app runs. But figwheel-sidecar is only required when current boot task is compose of =figwheel= task.

** License

Copyright © 2015-2016 aJchemist

Licensed under Eclipse Public License.