My specific problem involves fastclick.js, but I hope the question is of 
general interest to anyone using :foreign-libs.

I tried using fastclick.js in my project through :foreign-libs, with these 
compilation settings:

:foreign-libs [{:file "resources/vendor/fastclick/fastclick.min.js"
                :provides ["FastClick"]}]

And required it:

(ns my-project.core
  (:require ; ... rest of require statements
            [FastClick]))

And finally invoked it at the root of my Om app:

(defn main []
  (.attach js/FastClick (.-body js/document))
  (om/root main-view
    app-state
    {:target (. js/document (getElementById "app"))}))


Luke Vanderhart's comprehensive article[1] says "defining a namespace for a 
file using :foreign-libs doesn't actually scope any variables the library 
creates - if the library is built to insert a Foobar object at the global 
JavaScript context, for example, you'd still need to refer to it at the global 
context with js/Foobar, not namespace/Foobar"

This is how FastClick works. With {:optimizations :none}, everything is fine; 
but with {:optimizations :advanced}, although FastClick is added to the global 
scope with un-munged method names, my code uses a munged method name. It 
attempts to call FastClick.Td.

FastClick is compatible with advanced compilation[2], so I don't think that's 
the issue. Is there something else I can do to preserve the correct references?

For now, I'm just adding fastclick in a script tag in my HTML and supplying 
externs, which is honestly fine, but it would be cool to get the full benefit 
of advanced compilation.


[1] http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html
[2] https://github.com/ftlabs/fastclick/issues/1

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to