bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.88k stars 209 forks source link

When using sidecar with nREPL, :preloads flag can't find namespace unless specify cljs source path in clj :source-paths #566

Closed visibletrap closed 7 years ago

visibletrap commented 7 years ago

Normally, I separate Clojure and Clojurescript sources to src/clj and src/cljs. And I set src/clj to leiningen's root-level source-paths and specify src/cljs to source-paths in cljs compiler option. I have been using all these three approach to start figwheel, lein-fighweel, clojure.main repl + sidecar and nrepl + sidecar, everything has been working great.

When I add :preloads flag to cljs compiler config and starts with nrepl. Figwheel shows this warning

WARNING: preload namespace my.namespace does not exist

I also can't load that namespace in the figwheel repl. This issue doesn't appear when using figwheel via lein-figwheel and clojure.main repl.

I have found a workaround for this. Adding src/cljs to root-level source-paths fixes the issue. There's no more warning and the namespace is loaded correctly in figwheel repl.

bhauman commented 7 years ago

When you config outside of leinigen you need to quote your symbols.

Leinigen auto-quotes all raw symbols in the project.clj

On Mon, Jul 3, 2017 at 8:26 PM, Nuttanart Pornprasitsakul < notifications@github.com> wrote:

Normally, I separate Clojure and Clojurescript sources to src/clj and src/cljs. And I set src/clj to leiningen's root-level source-paths and specify src/cljs to source-paths in cljs compiler option. I have been using all these three approach to start figwheel, lein-fighweel, clojure.main repl + sidecar and nrepl + sidecar, everything has been working great.

When I add :preloads flag to cljs compiler config and starts with nrepl. Figwheel shows this warning

WARNING: preload namespace my.namespace does not exist

I also can't load that namespace in the figwheel repl. This issue doesn't appear when using figwheel via lein-figwheel and clojure.main repl.

I have found a workaround for this. Adding src/cljs to root-level source-paths fixes the issue. There's no more warning and the namespace is loaded correctly in figwheel repl.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bhauman/lein-figwheel/issues/566, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAKQJSyf1T-cyqlKwhxgylQpW4Dx99zks5sKYaYgaJpZM4OMxeT .

visibletrap commented 7 years ago

Thanks for a quick response, Bruce.

I have tried both using config from leiningen ((start-figwheel!) without any argument) and setting an argument to (start-figwheel! config) with :preloads '[my.namespace]. In both cases, there's a warning shows up.

I have created a project to demonstrate this. It's generated by leiningen's figwheel template with a few modifications.

If you have time, can you clone it and try these.

Then try replacing :source-paths ["src/clj" "dev"] with :source-paths ["src/clj" "dev" "src/cljs"]

Thank you so much

bhauman commented 7 years ago

This is actually the normal behavior, lein figwheel adds the cljs :source-paths to the lein root :source-paths in the figwheel plugin. When you use figwheel without the plugin you need to add these paths to the :source-paths as you have done in your example.

There is no good way to fix this behavior, as you have to set it up when you start the JVM process.

On Mon, Jul 3, 2017 at 11:08 PM, Nuttanart Pornprasitsakul < notifications@github.com> wrote:

Thanks for a quick response, Bruce.

I have tried both using config from leiningen ((start-figwheel!) without any argument) and setting an argument to (start-figwheel! config) with :preloads '[my.namespace]. In both cases, there's a warning shows up.

I have created a project to demonstrate this https://github.com/visibletrap/preload-can-not-find-ns. It's generated by leiningen's figwheel template with a few modifications https://github.com/visibletrap/preload-can-not-find-ns/commit/0eddbc2db97eda51b84f5b0874a364f00ae2c108 .

If you have time, can you clone it and try these.

  • lein figwheel: no warning
  • Run lein repl, then run (fig-start): warning shows up
  • Run lein repl, then run (fig-start-with-direct-args): warning shows up

Then try replacing :source-paths ["src/clj" "dev"] with :source-paths ["src/clj" "dev" "src/cljs"]

  • Run lein repl, then run (fig-start): no warning
  • Run lein repl, then run (fig-start-with-direct-args): no warning

Thank you so much

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bhauman/lein-figwheel/issues/566#issuecomment-312769958, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAKQC6TqcfI6rLro65cXMbfEYF8fg9dks5sKay8gaJpZM4OMxeT .

visibletrap commented 7 years ago

Got it. Thank you so much for the explanation. I'm good with adding path myself.

For people who later landed to this issue, I deleted my example project. I captured changes into images here

screen shot 2017-07-04 at 11 23 59 am screen shot 2017-07-04 at 11 24 12 am screen shot 2017-07-04 at 11 24 19 am