On Tue, Feb 7, 2012 at 8:18 AM, Base <basselh...@gmail.com> wrote:
> For the former, it is easy enough to just add the reference to the
> project.clj and it automagically appears in the lib.
>
> Does the same hold true for Clojurescript libraries?  I cannot seem to
> get this to work correctly and end up dropping the files in the
> directory defined in the :source-path in the project.clj.

I just went thru this last night with Chris Granger's jayq wrapper for jQuery.

I added a standard project.clj dependency on the library [jayq
"0.1.0-SNAPSHOT"] and lein deps brought it in as expected.

Things worked fine in :whitespace and :simple mode (:optimizations)
but broke in :advanced mode. The reason was that externs (declarations
of library names) was not picked up from the classpath (yet). The fix
was to run:

jar xf lib/jayq-*.jar externs

in my project to extract the externs folder (containing the jquery.js
declarations) into the top-level of my project. Forcing a recompile of
the cljs then solved the problem.

Another problem I ran into initially was not specifying :output-dir in
the compilation options. The compiler caches the source cljs and
compiled js and when I updated the jayq library (to pick up a fix from
Chris - thank you!), the old source was still being used. Once I
specified :output-dir I could see the problem and removing the
generated files (or using lein cljsbuild clean) emptied that cache and
forcing a recompile picked up the new source from the jayq JAR.

Oh, and my first problem was that with multiple :use clauses for
different cljs files in my ns declaration, the compiler seemed to get
confused about which namespace symbols lived in so it would produce
example.core.$.call(...) instead of jayq.core.$.call(...) or
example.core.by_id(...) instead of example.util.by_id(...). I finally
gave up on :use'ing multiple cljs code packages. I've had similar
problems with :require but can't track down the specific situation
that works vs fails (yet).

Small problems but frustratingly hard to debug because a) the
compilation produces giant JS files in non-advanced mode and
incomprehensible JS files in advanced mode and b) the g-Closure
compiler is a big black box so it's really hard to tell what's going
on. I also (sometimes) got an HTTP request for /deps.js which no one
on IRC seemed to be able to explain (so I just created an empty
deps.js file to shut it up).

ClojureScript is very promising - and I much prefer writing Clojure to
writing JS - but as soon as you stray from a specific published
example or from the simplest possible thing that works, you can get
into a landmine-filled world of frustration at the moment. Things are
improving rapidly tho'...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to