Fork me on GitHub

what's the right way to ignore cljs-devtools for an advanced-mod prod build


id est (devtools/install!)


I guess I could have a different entrypoint for dev but seems weird


(if ^boolean js/goog.DEBUG (devtools/install!))


found my answer


@bpicolo: interesting, have you noticed performance issues?


richiardiandrea: nope, just don't want dev artifacts in a production build


@bpicolo: we have three src folders, src, dev-src, prod-src. Dev tools only gets required in dev-src.


@bpicolo: agree I was just curious :)


I'd like to develop a client side only SPA that is pre rendered for download speed and user experience. Wondering what option would be best Om or Reagent.


@grounded_sage: this is like car-choosing process? what you prefer honda or toyota? reagent is easier to start, btw, so may be critical if it really first app using clojure.


@rmuslimov: I've built a few different static sites using a few libs. Currently venturing into the CLJS side of things a bit more. Been contributing to Braid chat which uses Om Now. Just wondering what would be better. Primarily for server side rendering story and handling the data. Not afraid of a little slow to get started (investing in learning) if it pays off.


@grounded_sage: apart from the cosmetic difference the main differentiator is how they manage state. Read up on om cursors and reagent atoms and om next transactor and take your pick


For getting off the ground quickly though reagent is a good choice


however om.cursor and is opposite right? is that true that is best for new projects, or people still consider using previous Om?


@plexus: cheers. I am leaning more towards Reagent at present. Despite being very interested in Om Next.


don't forget about Hoplon if you're looking for something simpler


I'm betting on React so focusing my efforts towards using something that uses it. I'd go straight for Om Next if it wasn't for such a huge divide in the community with heaps saying Reagent is better.


I dunno...I'm using Om.prev and considering whether to upgrade to or switch to looks heavy but I'm not sure I like Reagent's pattern of distributing state over many atoms, and I don't like seeing derefs in functions


@octo221: you can start out with one global state atom in Reagent. We did that. Currently we have a few components that maintain their own state atom, usually when they maintain some transient state, or when they wrap a stateful JS-component (like Openlayers).


We went from Om.prev to Reagent, and the whole team really like the data-first approach.


Is there a cljs function akin to clojure.core/format that allows for specifying positions, like (format "%2$s %1$s" a b)?


goog.string/format doesn't seem to include this functionality


@grav: my app has global undo (not through Om, just using a normal vector to store states), how easy is it to get global undo with Reagent ?


@octo221: it should be just a matter of reset’ing the global state atom.


and all the child atoms will be updated accordingly ?


and do the states of child atoms derive from that of the parent always ?

Roman Liutikov10:04:26

Are there any known issues with cjs/es6 modules used as foreign libs? Doesn’t seem to work for me 😞


anyone got React.addons.TransitionGroup working with Reagent (not the CSSTransitionGroup) ?


Has anyone managed to get a remote clojurescript browser repl to run when developing in cordova/mobile?

Roman Liutikov12:04:31

It looks like it’s not possible to require a function from cjs/es6 module if that function is a default export. Meaning that the namespace becomes a function itself. Is there a way around? I could re-export default export as named export from another module, but maybe there’s a better way.


@roman01la: seems like a generic question about ES6 module support, probably something you can ask on the Closure mailing list if you don’t get an answer here

Roman Liutikov16:04:27

@dnolen: Sorry, I don’t think it’s a problem of GCC. The problem that I described is more about CommonJS modules and it seems like there’s no really way around it. Because that’s how CJS exports work. But there’s a weird thing is going on with ES6 default exports. Let’s say I have the following ES6 module:

function a() { return 1;}
export default a;
When compiled, a value of var a will be assigned to default property of a namespace object. But when I try to require that namespace in ClojureScript and call default var from it (`(lib/default)`), in compiled JS output it looks something like this: module$lib$default$.call(). Notice that a symbol $ was appended to default, but it should be just default, because that’s where the var is assigned.

Roman Liutikov16:04:32

Not sure I’m explaining this well...


@roman01la: oh hrm this may be something we want to tweak in munging then


currently we munge based on ECMA-262, we should probably respect the language settings


patch welcome for something like this of course


currently default will always be munged to default$


@jonathandale: nice to see you on a cljs thread!


@jamieorc Yep, almost finished a side-project in re-frame, and started to work on a cljs project at work. Enjoying it.


I have a single function which doesn't use any clojure specific stuff. How would I build a js lib out of it, so I can call it in js? It's in a clojure backend, but I need to use it for another project in the front end


what's the clojure way of doing that?


copying it into it's own directory seems flakey


"copying and keeping a cljs/clj version separately"


@base698: I don’t quite understand how exporting clojurescript function to be visible from javascript can potentially have anything to do with words “clojure”, “backend” and “own directory”. If you have clojurescript function and you want it to be visible from javascript under :advanced optimzations use ^:export metadata to tell compiler to preserve its name


@base698: like js interops?


I have a clojure function, it's in a clojure project. the algorithm in said clojure function needs to be run from javascript, so i need to have some way to take just that one function, compile it to JS and run it from another app


so options are: make a cljs build separately, with another dir structure and when I run that copy just the one function into it, do the build, import that build from another project


right now I ship the clojure jar to artifactory, i'd make a separate deploy job that shipped the js somewhere else


yes the cljs build sounds like the way i have seen people do it before.


then you have three tasks at hand: 1) turn that clojure function into clojurescript function (even if it means just renaming the file extension from .clj to .cljs) 2) compile clojurescript project using your favorite tooling and produce javascript file(s) 3) make sure that selected clojurescript functions are exported as javascript API


Yeah, sounds right


How do you make your own lein tasks, to do things like rename a file etc?


I’m afraid it is not a good idea to use lein task for generating source files


what about a sym-link? or use clojure macro to generate clojurescript code (advanced)


the macro idea could work.


maybe symlink too


will have to try that


or use cljc extension, that is the best way I think


this will open a possibility to write platform-dependent parts using reader conditional (if ever needed in the future)


hello all, what is the diff from '(defn contact [c] [:li [:span (display-name c)] [:button {:on-click #(remove-contact! c)} "Delete"]])' and '(defn contact [c] [:li [:span (display-name c)] [:button {:on-click (remove-contact! c)} "Delete"]])' What is the use of #?


The hash # creates another function. The first version means function () { remove-contact! c} and the second means run remove-contact! c now.


you likely meant the first


You can see the difference when the code is expanded

user=> (macroexpand-1 '#(remove-contact! c))
(fn* [] (remove-contact! c))
user=> (macroexpand-1 '(remove-contact! c))
(remove-contact! c)


Has anyone come up with a way to provide a convenient console.log fn? I have this…

(defn log [& args]
  (.log js/console (clj->js args)))
But it has the downside of not mapping properly to the invoker, so I can’t inspect the source and find who is doing the logging.


(i.e. every call to log looks like its coming from utils.core line:5)

Roman Liutikov20:04:09

@lwhorton: I guess a macro could help here

Roman Liutikov21:04:30

@dnolen: Regarding CLJS-1620, can you give any context on where to start? I’m pretty new to ClojureScript compiler. I guess :module-type information could be used to control munging.


@lwhorton: does setting *print-fn* to log and using println help?


@base698: I'm not certain I understand, but it sounds like you are talking about cljc. If you have a namespace in a cljc file, both clojure and clojurescript can require it. You can use the conditional reader to add code specific to the target language.


that sounds exactly what I need, where is that at?


sorry, I wrote that up before reading all the way down. ha. @darwin and others also recommend this approach.


Pretty cool. Exactly what I needed.