It seems to me that there has to be a simpler approach to what you are
trying to accomplish. To that end, what is your end goal, and why is "splitting
the cljs into a .cljs file is not an option"?

On Wed, Jan 27, 2016 at 12:08 PM, Gregg Reynolds <d...@mobileink.com> wrote:

>
>
> On Tue, Jan 26, 2016 at 9:03 PM, Matching Socks <phill.w...@gmail.com>
> wrote:
>
>> Is lein's project mavenry important here?  Could you call cljs.compiler
>> directly?
>>
>
> You mean instead of using 'lein cljsbuild auto'?  I can do that but I'm
> not sure how to "link" the cljs core lib.  Following David Nolen's
> excellent hello-cljsc <https://github.com/swannodette/hello-cljsc> tutorial
> I'm able to compile cljs forms and strings (using emacs, btw), but I've
> been doing it piecemeal.  The code to be compiled looks something like the
> following.  It represents Polymer declared properties
> <https://www.polymer-project.org/1.0/docs/devguide/properties.html> (I'll
> be posting detailed docs sometime in the next few weeks).
>
> (miraj.markup/defproperties MyProps
>   (^Boolean president true :read-only)
>   (^Number x 0 (fn [new old] (+ new old)) :notify :reflect)
>   (^String lname "Lincoln" (fn [new old] (.log js/console
>                                                (str "Old pres: " old ";
> new: " new)))))
>
> This gets translated to (part of) the javascript for a Polymer component.
> Were it not for the fn forms I could use a clj->json lib.  My first version
> supported embedded javascript function defs, but that seemed so very
> crass.  To support cljs I can pull out the fn forms and feed to a compile
> macro:
>
> (println (miraj.markup/cljs-compile '(fn [x y] (.log js/console "foo"))))
> =>
> (function(a, b) {
>   return console.log("foo");
> });
>
> But with anything more complicated the core lib is referenced and you have
> to deal with namespaces:
>
> (println (miraj.markup/cljs-compile '(defn f [] (this-as this
>                                                          (if x
>                                                            (.log
> js/console "foo")
>                                                            (.log
> js/console "bar"))))))
> =>
> WARNING: Use of undeclared Var cljs.user/x at line 32
> cljs.user.f = function() {
>   return cljs.core.truth_(cljs.user.x) ? console.log("foo") :
> console.log("bar");
> };
>
> Plus I don't think there would be any way to compile with :advanced
> optimization this way.  Or is there?  I'm under the impression that
> optimization must be done globally.  I wonder if there is a way to use the
> compile/analyze etc. APIs to do it piecemeal or break it into steps somehow.
>
> In the end I just wrote code that as a side effect generates one piece of
> cljs for the whole lot and writes it to disk, as I mentioned.  Not really
> that different than what standard def* macros do anyway, I'm just
> "interning" stuff to disk rather than the local namespace.  I could skip
> the write to disk step (or make it optional for debugging) and compile
> directly, but I'm not sure how one would then "link" the cljs/closure lib.
>
> I guess another option would be to keep a cljs repl running during
> development and feed it generated cljs.
>
> Thanks,
>
> Gregg
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to