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!
On Thu, Oct 4, 2012 at 12:40 PM, Andrew <ache...@gmail.com> wrote:
> 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!
There is too much context here. Can you isolate the problem and create a
minimal case? If you can it would be extremely helpful if you could create
an issue in JIRA w/ this information.
Ok, I've made *some* progress in ripping out code unrelated to this issue. So far it seems if I remove any more the issue disappears. See https://github.com/achengs/subparissue1
It's a mystery to me why ...
- removing any of the three arguments to the loop/recur in the parse function in https://github.com/achengs/subparissue1/blob/master/src-cljs/subpar/c... prevents the exception from being thrown (the issue goes away and both output js files behave the same) - the so-called parse function interprets the first character from codemirror differently the second time you hit Alt-S on the demo page that reproduces the exception... but this difference in parsing doesn't show up on the page that demos normal behavior - removing the for loop in https://github.com/achengs/subparissue1/blob/master/resources/public/... for reindenting lines also makes the issue go away
On Thursday, October 4, 2012 1:02:08 PM UTC-4, David Nolen wrote:
> On Thu, Oct 4, 2012 at 12:40 PM, Andrew <ach...@gmail.com <javascript:>>wrote:
>> 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!
> There is too much context here. Can you isolate the problem and create a > minimal case? If you can it would be extremely helpful if you could create > an issue in JIRA w/ this information.
On Fri, Oct 5, 2012 at 8:16 AM, Andrew <ache...@gmail.com> wrote:
> 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.
Yes Closure assumes whole program optimization. You can't use two
separately advanced compiled pieces of JS code together.
On Friday, October 5, 2012 8:21:09 AM UTC-4, David Nolen wrote:
> On Fri, Oct 5, 2012 at 8:16 AM, Andrew <ach...@gmail.com <javascript:>>wrote:
>> 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.
> Yes Closure assumes whole program optimization. You can't use two > separately advanced compiled pieces of JS code together.
On Fri, Oct 5, 2012 at 8:38 AM, Andrew <ache...@gmail.com> wrote:
> How do I tell Closure to include Codemirror.js and other js files when it
> optimizes?
After I read the link you provided and another page<http://code.google.com/p/closure-compiler/wiki/FAQ#When_using_Advance...>, 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<https://github.com/emezeske/lein-cljsbuild/issues/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.
On Fri, Oct 5, 2012 at 2:37 PM, Andrew <ache...@gmail.com> wrote:
> After I read the link you provided and another page<http://code.google.com/p/closure-compiler/wiki/FAQ#When_using_Advance...>,
> 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<https://github.com/emezeske/lein-cljsbuild/issues/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.
You don't need to do that. That's what the :foreign-libs option is for
which is described at the end of blog post.
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?)
On Friday, October 5, 2012 2:39:34 PM UTC-4, David Nolen wrote:
> 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.
> You don't need to do that. That's what the :foreign-libs option is for > which is described at the end of blog post.
On Sat, Oct 6, 2012 at 11:14 PM, Andrew <ache...@gmail.com> wrote:
> 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?)
Seems like a simple useful option we should expose.