Please see https://github.com/achengs/subpar/issues/1 which links to two demo pages. One page uses the debug (non-optimized non-munged) js version and seems to work fine. The other uses the optimized version and throws an exception. Details are in the github issues page and on the demo pages themselves. I'm wondering why they behave differently. Thanks in advance for any help!
Oh. I'm pretty sure it's because in the broken case I use two blobs of js which were minified at separate times thus allowing for name conflicts.
How do I tell Closure to include Codemirror.js and other js files when it optimizes?My project.clj file has this::cljsbuild {:builds {:prod{:source-path "src-cljs":compiler {:output-to "resources/public/js/subpar.core.js":optimizations :advanced:pretty-print false}}}
After I read the link you provided and another page, I discovered that wrapping my compiled stuff in an anonymous function keeps Google Closure's output symbols from colliding with other existing stuff such as CodeMirror's minified variables.
That link points out that it's best to have the compiler do the wrapping for you with --output_wrapper. Is there a way to specify this for cljsbuild? lein-cljsbuild issue #117 says cljsbuild is just a wrapper for the ClojureScript compiler and if we want it we should open a ticket for ClojureScript. I looked and did not immediately see a ticket or the wrapper option. So maybe I'll open that ticket?
By the way, I'm not sure compiling CodeMirror and my stuff in one go is the right approach, because I don't know whether CodeMirror is compatible with Google Closure's advanced compilation. (I see that CodeMirror 1's compression page had Google Closure advanced optimization as an option but it disappeared for CodeMirror 2.) I think doing so would require me to hand-edit CodeMirror to add a goog.provide call.
What about the --output_wrapper part?My clojurescript js never calls the minified foreign library directly: What I have is [1] some plain non-optimized javascript that calls [2] CodeMirror for the code and position, then calls [3] my clojurescript js to find out how to do the requested paredit thing, and then calls [2] CodeMirror again to do it.So [3] never calls [2][2] and [3] export stuff so that [1] can call them.And my problem is that [2] isn't wrapped in an anonymous function. How do I get cljsbuild to tell Closure to use --output_wrapper? (Also, I guess there's a good reason why it doesn't always wrap its output?)