boot-clj / boot-cljs

Boot task to compile ClojureScript programs.
Eclipse Public License 1.0
176 stars 40 forks source link

cljs :ids option prevents release/js/<target>.js file creation? #132

Closed gamecubate closed 8 years ago

gamecubate commented 8 years ago

I have 2 output targets for my project (teaser, and app) and am trying to restrict compilation to one .cljs.edn file per target.

To do that, I use the :ids #{...} cljs option. Here is one of my targets, named teaser:

(deftask teaser []
  (task-options! cljs {:optimizations :advanced :ids #{"teaser"}})
  (comp
    (speak)
    (cljs)
    (sift :include #{#"teaser.html" #"css/*" #"media/*" #"js/teaser.js"})
    (target :dir #{"release"})
    ))

Here are the contents of the target's corresponding .cljs.edn file:

$ cat resources/js/teaser.cljs.edn
{:require  [app-1.app]
 :init-fns [app-1.app/teaser]
 :compiler-options {:asset-path "js/teaser.out"}}

$ boot teaser performs the compilation without errors but does not output the teaser.js file (nor does it create the release/js folder).

Strangely enough, removing the :ids cljs option results in the creation of the desired output file (release/js/teaser.js) but I assume that the processing of all .cljs.edn files slows down the compilation process (correct me if I am wrong).

Am I missing something?

FWIW, here is my build.boot:

(set-env!
 :source-paths    #{"src/cljs"}
 :resource-paths  #{"resources"}
 :dependencies '[[adzerk/boot-cljs          "1.7.228-1"  :scope "test"]
                 [adzerk/boot-cljs-repl     "0.3.2"      :scope "test"]
                 [adzerk/boot-reload        "0.4.12"     :scope "test"]
                 [pandeiro/boot-http        "0.7.2"      :scope "test"]
                 [com.cemerick/piggieback   "0.2.1"      :scope "test"]
                 [org.clojure/tools.nrepl   "0.2.12"     :scope "test"]
                 [cljsjs/moment             "2.10.6-4"]
                 [cljs-ajax                 "0.5.8"]
                 [weasel                    "0.7.0"      :scope "test"]
                 [org.clojure/clojurescript "1.7.228"]])

(require
 '[adzerk.boot-cljs      :refer [cljs]]
 '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
 '[adzerk.boot-reload    :refer [reload]]
 '[pandeiro.boot-http    :refer [serve]])

(deftask teaser []
  "Compile teaser for final release"
  (task-options! cljs {:optimizations :advanced :ids ${"teaser"})
  (comp
    (speak)
    (cljs)
    (sift :include #{#"^teaser.html" #"css/*" #"media/*" #"js/teaser.js"})
    (target :dir #{"release"})
    ))

(deftask app []
  "Compile full app for final release"
  (task-options! cljs {:optimizations :advanced :ids ${"app"})
  (comp
    (speak)
    (cljs)
    (sift :include #{#"index.html" #"css/*" #"media/*" #"js/app.js"})
    (target :dir #{"release"})
    ))
Deraen commented 8 years ago

Ids option uses the full path instead of just the filename, I'm afraid this is documented only on the changelog: 1.7.48-3

gamecubate commented 8 years ago

I followed your suggestion:

(deftask teaser []
  (task-options! cljs {:optimizations :advanced :ids #{"resources/js/teaser.cljs.edn"}})
  (comp
    (build)
    (sift :include #{#"^teaser.html" #"css/*" #"media/*" #"js/teaser.js"})
    (target :dir #{"release"})
    ))

Running the teaser task seems to work:

$ boot teaser
Writing teaser.cljs.edn.cljs.edn...
Compiling ClojureScript...
• resources/js/teaser.cljs.edn.js
Sifting output files...
Writing target dir(s)...

However, this still does not result in creation of release/js/teaser.js:

$ ls release/
css     media       teaser.html
Deraen commented 8 years ago

Though the option takes full path, it doesn't take the extension.

gamecubate commented 8 years ago

Success. Thanks a lot. I had to tweak the task, changing :ids from #{"resources/js/teaser"} to #{"js/teaser"}. Wiki documentation for this option seems a bit sparse. It would be good for users to flesh it out.