Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make :main compatible with Figwheel #26

Closed
bensu opened this issue Sep 7, 2015 · 2 comments
Closed

Make :main compatible with Figwheel #26

bensu opened this issue Sep 7, 2015 · 2 comments

Comments

@bensu
Copy link
Owner

bensu commented Sep 7, 2015

There are three ways to specify :main:

  1. :main 'app.core
  2. :main app.core
  3. :main "app.core"

We should support all of them. As noticed by @teaforthecat we currently don't support 2. which is Figwheel's preferred method.

  1. Is important since it is used in scripts for the compiler, and beginners will probably paste those to project.clj.
@dqdinh
Copy link

dqdinh commented Sep 25, 2015

I had the following bug below while using doo and figwheel.

 $ lein clean; lein figwheel 
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Named
 at clojure.core$name.invoke (core.clj:1524)
    clojure.lang.AFn.applyToHelper (AFn.java:154)
    clojure.lang.AFn.applyTo (AFn.java:144)
    ...

After several hours of leiningen config trial and error, it turns out that Figwheel will specifically error out if it sees :main 'app.core. Options 2 and 3 will work.

It might help prevent others from spending time debugging if the :main 'app.core in the README and example config was changed to Option 2 or 3. The error only occurs when specifying :main 'app.core inside :cljsbuild {:builds {:build-id {:compiler ...} and calling lein figwheel. All other cljsbuild commands work.

This is my current working project.clj for reference.

(defproject frontend "0.1.0"
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.48"]
                 [reagent "0.5.1-rc3"]
                 [re-frame "0.4.1"]
                 [environ "1.0.0"]
                 [prismatic/schema "1.0.1"]
                 [prismatic/plumbing "0.4.4"]
                 [figwheel "0.4.0"]
                 [cljs-ajax "0.3.14"]]

  :plugins [[lein-environ "1.0.0"]
            [lein-figwheel "0.4.0"]
            [lein-cljsbuild "1.0.6"]
            [lein-doo "0.1.5-SNAPSHOT"]
            [codox "0.8.13"]]

  :source-paths ["src"]

  :codox {:language :clojurescript
          :exclude clojure.string}

  :profiles {:dev {:env {:dev? true
                                    :cors? true}

                           :cljsbuild {:builds {:client {:figwheel {:on-jsload "frontend.core/mount-root"}
                                                                   :compiler {:main "frontend.core"
                                                                        :source-map true
                                                                        :source-map-timestamp true
                                                                        :optimizations :none
                                                                        :output-dir "resources/public/js/out"
                                                                        :asset-path "js/out"}}}}}}

  :clean-targets ^{:protect false} [:target-path
                                    :compile-path
                                    "resources/public/js"
                                    "../public/frontend-dev"
                                    "../public/frontend-prod"]

  :cljsbuild {:builds {:client {:source-paths ["src"]
                             :compiler {:output-to "resources/public/js/main.js"}}

                       :browser-test {:source-paths ["src" "test"]
                                      :compiler {:output-to "resources/public/js/browser_tests.js"
                                                 :main "frontendtest.browser"
                                                 :optimizations :none}}}}

  :figwheel {:css-dirs ["resource/public/css"]
             :server-port 3333
             :repl false})

@flosell
Copy link

flosell commented Sep 26, 2015

+1 to changing the examples in README.md to something like :main "example.runner", would have saved me half an hour of debugging and googling.

@bensu: Any doubts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants