Need help with advanced optimization

246 views
Skip to first unread message

Andrew S

unread,
Jan 30, 2015, 3:30:41 AM1/30/15
to clojur...@googlegroups.com
I need another set of eyes on this to see what I'm doing wrong. This is my project.clj:

https://www.refheap.com/96680

At the command line, I do this:

lein with-profile prod cljsbuild once

It does a number of things that are apparently not right:

1) It spits out the main js file that only has this in it:

;(function(){

})();

2) It still generates an out/ dir with separate js files for each cljs namespace.

3) The compiler gives me a circular dependency error when there is none in my code, and the :none optimizations work fine. The error says this:

Jan 30, 2015 9:24:51 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: ERROR - Circular dependency detected: appjs.session -> appjs.session

Jan 30, 2015 9:24:51 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 1 error(s), 0 warning(s)
ERROR: JSC_CIRCULAR_DEP. Circular dependency detected: appjs.session -> appjs.session at (unknown source) line (unknown line) : (unknown column)

I'm sure I'm doing something obvious, if anyone can tell what it is, let me know. Leiningen is a bit of a mystery to me.

Andrew

--
hellofunk

Thomas Heller

unread,
Jan 30, 2015, 4:21:04 AM1/30/15
to clojur...@googlegroups.com
1) The main js file is empty because of the closure compiler error. The circular dependency is somewhere in your code, usually :none should detect it as well but difficult to tell without the source.

2) I do not think the cljsbuild config should be in a profile.

https://www.refheap.com/96682

Try defining a :dev and :prod build and then run

lein with-profile prod cljsbuild once prod

or in dev

lein cljsbuild auto dev


HTH,
/thomas

Hello Funk

unread,
Jan 30, 2015, 5:34:48 AM1/30/15
to clojur...@googlegroups.com
Thanks Thomas. I tried your version of the project.clj. Should the
output directory be the same in both dev and prod? Because when I set
them the same, I get this when trying the prod build:

Error encountered performing task 'cljsbuild' with profile(s): 'prod'
java.lang.Exception: All [:compiler :output-dir] options must be distinct.
> --
> Note that posts from new members are moderated - please be patient with your first post.
> ---
> You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/Boc3w0BbNCw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
> To post to this group, send email to clojur...@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.



--
hellofunk

Andrew S

unread,
Jan 30, 2015, 5:51:05 AM1/30/15
to clojur...@googlegroups.com
Ok, I've gotten a bit further and have the following question:

1) Thomas, I was able to get the compile to complete using my original
refheap, which incidentally follows the chestnut template so I think
the structure of those options is ok.

2) I don't understand why there are still individual js files for each
of my namespaces put into the out/ dir. Isn't the idea of an advanced
compile to combine everything into a single file? Or is it that I can
remove those files in the out/ dir after compile completes, that those
are just intermediate necessities while it completes the main js file?

3) Why is the profile name specified twice in the command you noted:

lein with-profile prod cljsbuild once prod

4) I got around the circular dependency by just removing the problem
namespace for now. But I don't understand why the compiler would
report a circular dependency in the first place. First of all, the app
works fine with no warning with optimizations are :none. Second, this
namespace :requires 3 other of my namespaces, plus core.async. None of
those other namespaces are :requiring this problem namespace reported
in the circular dependency. Isn't a circular dependency when File A
requires File B, and vice versa? If so, that is not happening here.
Now, both files can require File C, that's fine, right?
--
hellofunk

Thomas Heller

unread,
Jan 30, 2015, 10:52:33 AM1/30/15
to clojur...@googlegroups.com
Haven't used cljsbuild for a while, so I cannot say with 100% confidence.

2) output-to should be a single "target" file, output-dir for for everything else which you may need if you compile with source-maps for example. The individual files are also for caching to allow incremental compiles. You should not need those at runtime (unless you want source-maps)

3) one is the name of the leiningen profile, the other is the name of the cljsbuild profile. You may have multiple build targets, specifying the name (after once) will only build the one instead of all.

4) I cannot say why it doesn't without the source. You might be doing something cloSure detects but cljs doesn't (eg. manually doing a goog.require). circular can also be further down A -> B -> C -> A, anywhere on the graph really.
Reply all
Reply to author
Forward
0 new messages