Вопрос

If in a .cljs file I define a file like this:

main.cljs

   (ns project.main
      (:use [project.secondfile :only [my-var]]))

   (js/alert my-var)

secondfile.cljs

   (ns project.secondfile)
   (def my-var "Hi")

I get a "Referred var project.secondfile/my-var does not exist at src-cljs/main.cljs". However, it works normally in the browser as both are compiled (and with compilations :whitespace they can reference each other just fine). But obviously, it doesn't work in the bREPL as they aren't referring to each other.

Is this something unavoidable or I'm doing something wrong?

Thanks!

Это было полезно?

Решение

I've tried your code and works fine in my current configuration. I've had other issues similar to your question and in those cases you can try to compile and load the secondfile.cljs into the brepl before you try to compile and load the main.cljs. In this case, this trick works fine. Maybe the problem is that the secondfile.cljs (and the def my-var ) didn't exist before the cljsbuild compilation, so when you tried to use this my-var this code wasn't available

I hope this helps you
Juan

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top