boot-clj / boot-figreload

Boot task providing live-reload using Fighweel client
Eclipse Public License 1.0
49 stars 1 forks source link

hoplon + boot-figreload generates invalid edn #10

Open freakinruben opened 7 years ago

freakinruben commented 7 years ago

Not sure weather this is an issue of hoplon or boot-figreload but since the invalid string in the index.html.edn.cljs is added by boot-figreload I assume it belongs here.

I'm trying to use hoplon with boot-figreload. Hoplon generated an .cljs.edn file which normally lookes something like:

{:require [hoplon.app-pages._index_DOT_html adzerk.boot-reload.index adzerk.boot-cljs-repl]}

Now, with boot-figreload a long invalid namespace is added to the edn:

{:require [hoplon.app-pages._index_DOT_html figwheel.connect./Users/foo/.boot/cache/tmp/Users/foo/Projects/MyProject/ra0/-u2t4ne/index.html.cljs.edn-ef950fab]}

Resulting in an error when I try to compile the cljs:

Writing HTML files...
• index.html
Writing figwheel.connect./Users/foo/.boot/cache/tmp/Users/foo/Projects/MyProject/ra0/-u2t4ne/index.html.cljs.edn-ef950fab namespace to index.html.cljs.edn_ef950fab.cljs...
Adding :require(s) to index.html.cljs.edn...
nREPL server started on port 9009 on host 127.0.0.1 - nrepl://127.0.0.1:9009
Adding :require adzerk.boot-cljs-repl to index.html.cljs.edn...
Compiling ClojureScript...
                              java.lang.Thread.run              Thread.java:  748
java.util.concurrent.ThreadPoolExecutor$Worker.run  ThreadPoolExecutor.java:  617
 java.util.concurrent.ThreadPoolExecutor.runWorker  ThreadPoolExecutor.java: 1142
               java.util.concurrent.FutureTask.run          FutureTask.java:  266
                                               ...
               clojure.core/binding-conveyor-fn/fn                 core.clj: 1938
                                 boot.core/boot/fn                 core.clj: 1029
                               boot.core/run-tasks                 core.clj: 1019
                    boot.task.built-in/fn/fn/fn/fn             built_in.clj:  427
                 boot.task.built-in/fn/fn/fn/fn/fn             built_in.clj:  430
              boot.task.built-in/fn/fn/fn/fn/fn/fn             built_in.clj:  430
              hoplon.boot-hoplon/eval4202/fn/fn/fn          boot_hoplon.clj:  162
       powerlaces.boot-figreload/eval4417/fn/fn/fn       boot_figreload.clj:  221
    powerlaces.boot-figreload/eval4417/fn/fn/fn/fn       boot_figreload.clj:  222
                    boot.task.built-in/fn/fn/fn/fn             built_in.clj:  477
                    boot.task.built-in/fn/fn/fn/fn             built_in.clj:  479
            adzerk.boot-cljs-repl/eval368/fn/fn/fn       boot_cljs_repl.clj:  187
                 adzerk.boot-cljs/eval210/fn/fn/fn            boot_cljs.clj:  174
                 adzerk.boot-cljs/eval265/fn/fn/fn            boot_cljs.clj:  274
                                clojure.core/doall                 core.clj: 3039
                                clojure.core/dorun                 core.clj: 3024
                                  clojure.core/seq                 core.clj:  137
                                               ...
                               clojure.core/map/fn                 core.clj: 2646
              adzerk.boot-cljs/eval265/fn/fn/fn/fn            boot_cljs.clj:  276
                        adzerk.boot-cljs/compile-1            boot_cljs.clj:  152
                 adzerk.boot-cljs/assert-cljs-edn!            boot_cljs.clj:  125
java.lang.AssertionError: Assert failed: Every .cljs.edn :require item should be a symbol referring to a namespace, i.e. symbol should only have a name:
                          [hoplon.app-pages._index_DOT_html figwheel.connect./Users/foo/.boot/cache/tmp/Users/foo/Projects/Prive/MyProject/ra0/-u2t4ne/index.html.cljs.edn-ef950fab adzerk.boot-cljs-repl]
                          (and (every? (fn [v] (and (symbol? v) (not (namespace v)))) (:require main)))

Snipped from build.boot:

(set-env!
  :dependencies
    '[[org.clojure/clojure          "1.9.0-alpha17"]
      [org.clojure/clojurescript    "1.9.671"]
      [hoplon                       "7.0.2"]
      [adzerk/boot-cljs-repl        "0.3.3"     :scope "test"]
      [adzerk/boot-cljs             "2.1.0-SNAPSHOT" :scope "test"]
      [com.cemerick/piggieback      "0.2.2"     :scope "test"]
      [weasel                       "0.7.0"     :scope "test"]
      [powerlaces/boot-figreload    "0.1.1-SNAPSHOT" :scope "test"]])

(require
  '[adzerk.boot-cljs            :refer [cljs]]
  '[adzerk.boot-cljs-repl       :refer [cljs-repl]]
  '[hoplon.boot-hoplon          :refer [hoplon]]
  '[powerlaces.boot-figreload   :refer [reload]])

(deftask run-cljs-dev []
  (comp
    (hoplon)
    (reload)
    (cljs-repl :nrepl-opts {:port 9009})
    (cljs :optimizations :none :source-map true)))
arichiardi commented 7 years ago

Thanks for the report, yes that does not look right at all. I am not familiar with hoplon at all but if you have a minimal repro repo, or want to use a branch in this repo I can have a look.

Also I see you haven't posted any .cljs.edn file here, just want to point out that it is mandatory for boot-figreload (and in general is good to have it for that matter).

freakinruben commented 7 years ago

I'm not super familiar with Hoplon myself, but here is the repo cloned and adjusted (to my best knowledge) for hoplon. Weather or not the hoplon part is correct, running boot dev will give the same error as I have with my own code.

About the .cljs.edn file, hoplon generates this for you. The generated edn before figreload with the repo above is:

{:require [figreload-demo.index adzerk.boot-cljs-repl]}

After:

{:require [figreload-demo.index figwheel.connect./Users/foo/.boot/cache/tmp/Users/foo/Projects/figreload-demo/6h7/-7bl902/index.html.cljs.edn-72fbe00c adzerk.boot-cljs-repl]}
arichiardi commented 7 years ago

Ok that is great thanks, I will have a look.

arichiardi commented 7 years ago

It looks like hoplon is creating a .cljs.edn file that fails my regex here...I don't have much time now, but a patch should be really trivial, I am basically taking the build-id, the part before cljs.edn which in your case above is index.html but really should be index.

vigilancetech-com commented 5 years ago

I replaced the (\w+) with ([a-zA-Z0-9_.]+) and even tho at the REPL, when given "index.html.cljs.edn" it returns "index.html" it still give the error.

I also changed it to ([a-zA-Z0-9_]+).(.+) which only returns "index" and no improvement.

I'd like to start using this ASAP. Any more ideas?

arichiardi commented 5 years ago

@vigilancetech-com what error do you get? Same as above? It's been a while but I though the regex would solve.