Fork me on GitHub

if I want a function useable in both cljs and clj, do I have to put the function in a cljc file, or is there a way to have cljs files include clj files and vice-versa ?

bbrinck02:07:25 You’ll need to put it in a cljc file


I'm making an Electron app. For Electron one is supposed to make two separate js files: one for the main process and one for the renderer process. But they are still one project. Can I have lein cljsbuild auto make both at the same time? And can I have figwheel autoload both?


Maybe I don't need to make both with one cljsbuild or figwheel process, hm...


Oh, I can with lein figwheel main renderer.


@oskarkv Oh nice, I used the cljs-electron template, which works around that by using lein cooper. Your way looks better 🙂


mrchance I spent 2 days setting up everything without a template. Didn't wanna use templates that I didn't understand. 😛


I liked that one, it's very simple. But in general, I agree ^^


I'm trying to use Electron with :npm-deps, but it says "JSC_JS_MODULE_LOAD_WARNING. Failed to load module "fs" at .../node_modules/electron/index.js" What am I supposed to do about that?


@oskarkv you can just (js/require "fs") since it's a builtin, not a node module


@mrchance Hm but Electron tries to require("fs") and that gives the warning. Maybe I don't need to care about it, but I'm new to all this so don't really know what is wrong. 😛


ok, that's mildly weird, don't know why it would try that, and why it wouldn't succeed


Why do you have electron in your node modules? I don't 🙂


It didn't complain when I was using (nodejs/require "electron") but now I'm trying (:require [electron :as e]) in the ns form @mrchance


It seems nicer, and the closure compiler is supposed to be able to optimize better, if I understand it correctly


That's probably wrong? The template uses (js/require ...) too


Yes, in general that's how it should work, but maybe electron works a little differently... Don't know


@anmonteiro Is here, maybe he knows 😉


How can I define compiler options that are common across builds for figwheel?


@oskarkv in case you are interested I added a quick electron example for shadow-cljs


the support for requiring node modules is a bit more solid there and should work for the main and renderer


I gotta run though, will be back later if you have questions


@thheller Hm, no :npm-deps?


so I'm trying out :npm-deps with :language-in :ecmascript5


and getting a lot of warnings like WARNING: JSC_BAD_JSDOC_ANNOTATION. Parse error. illegal use of unknown JSDoc tag "grep";


ignorable or fixable?


@deadghost You can suppress those by adding :closure-warnings {:non-standard-jsdoc :off} to your compiler options


is it possible to reuse out artifacts when building cljs, so that builds can reuse artifacts where they can?


@biscuitpants by “building cljs,” do you mean building the ClojureScript compiler itself?


Normally, stuff in out is reused by the compiler for performance reasons (


ah okay. so it can reused. we are trying to speed up our cljs builds, maybe you could help? we have 7 builds, and then another step at the end that does a transformation to the produced files. are multiple builds done in parallel? i.e more than 1 cljs build is built at a time (not just 1 build across multiple CPU’s)


@biscuitpants That would be handled by whatever build tooling you are using, if anything.


right. so it looks like lein-cljsbuild doesn’t do that, so we’d need to implement it ourselves?


Off the top of my head, I’d be wary about having multiple compilers running simultaneously working with the same out directory. I don’t think the ClojureScript compiler is set up to guard against things that might go wrong in this situation.


hmm, okay. is there anything else we can do to speed up builds? apart from changing the actual codebase?


Is this an issue at the end when you go to do an :advanced build? Or is it in the normal cycle you seen when doing normal development with :none?


:advanced build


@biscuitpants I don’t have any experience trying to make :advanced builds run faster. I usually just grab a cup of coffee 😞


haha, okay. well thank you! it may be an idea to look at other build tools


One thought @biscuitpants: Ensure you have set your JVM settings to have a reasonable (but not too much) RAM, and set it to a fixed amount. I’d experiment with that because it can make an order of 2 magnitude difference in some case.


ours are set to “-Xmx1024m” “-Xms1024m”


(If you let the JVM manage its own heap size, things can get really slow for some reason. Likewise, if you specify too large a heap, things can slow down)


@biscuitpants Try an experiment with 8g


ok gonna try that now


Also, another easy thing to do, if not done yet: Ensure you are using a recent version of ClojureScript. There were perf optimizations in the compiler added recently that can shave off 25%


yeah we recently bumped to the latest version. try to stay on the latest version


@oskarkv no :npm-deps, just manually install things via npm.


just to jump in here, @mfikes (ole @biscuitpants is a colleague) we’re building several :mains from a common codebase, which means all that stuff that happens before :advanced is repeated per :main — ie. the production of out artifacts. we’re hoping that we can somehow produce the entire out once, much like :none would, and then run the GCC phase in parallel, at 2x or 4x


what distinguishes our :main s from each other is manually selecting sub-components for a particular page’s use-case, to slim the JS those users would get. some of our js is half as big as some of the other js from the same process.


put another way, this is a poor man’s modules


@robert-stuttaford that sounds like you really should be using :modules? 🙂


i really really want it to be modules, but i ended up having to manually write ns lists for each module, which got old fast


i will say that it’s been a good long while since i’ve tried it again


don’t you have a and the like namespace setup?


ie. a namespace per page?


a main per page, which each use a different selection from a common set of components. all this code uses a defonce’d atom and a defonce’d async chan, to simplify state management. i suspect this is messing with the code-motion that modules uses; ie. glomming almost everything into the common module


nah that was just the old :modules with bad behaviour


omg don’t get my hopes up


@robert-stuttaford One thing to look out for is that all of the :mains are built with the same “build-affecting” options. So, for example, if one has :static-fns and another doesn’t, this would defeat reuse of stuff in out


ok we’ll try it. @mfikes good to know. happy to report that they’re all identical other than the main and js file name (and source map file name)


btw i don’t say this often enough - cljs is moving forward at a phenomenal speed, in large part thanks to the fine folks on here. thank you, thank you …


to match the example would I (:require [react-simplemde-editor :as SimpleMDE])?


then do something like (def mde (r/adapt-react-class SimpleMDE))?


@deadghost Yes, that would be the first thing I would try


hmm well if I continue from that and call it as [mde] or [mde {}], I get Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in. Check the render method of data-page.


Hi everyone! can anyone recommend resources for helping me decide between re-frame and (other than their respective docs)?


Checkout #re-frame community is a good start point to re-frame 😄


Hi all, fairly new to Clojure and until recently didn't realize clojurescript on node was even an option. Getting ready to build out a backend for a cljs app and am now wondering if I should try the cljs route vs clj since I'm much more familiar with Node than Java. Question is, is this approach ready for prime time? Any good examples/libraries you can point me to? No major requirements for this app; more for learning / experimenting with clj. thx!


ClojureScript on Node seems no more or less mature than running natively using JS to me.


Some things I’ve noticed though: 1. There’s no point in doing advanced optimization on backend stuff since none of it is being sent to a client. In fact, as it stands at the moment, you can run into some trouble when doing so. 2. I ran into problems doing server side rendering with the latest version of Reagent (0.7.0). I had to use the previous version in the end to get it to work (0.6.2).


Re: Reagent, this pretty much sums up the problems:


I'm also interested in this


pretty much my defacto go-to app server is node


would be nice to start using clojurescript there and then transition to something like ring/netty (once I'm more familiar with it)


the jvm clojure will use resources more efficiently and has a much simpler tooling setup, but cljs on the backend is definitely possible


for example most of the time you still need to run jvm clojure to build your cljs (self hosted cljs is possible but not as robust or featureful)


@fedreg I did start out a cljs/node.js project before. I needed some java libs. Apart from that, I'd say, cljs/node.js certainly has its use cases and I'd start cljs/node.js without much doubt


Thanks all for the info. Looks like it's experimentation time!


Yeah, just do it. You'll see, it's a breeze.


the best place to start IMO if you want to try cljs on the server


@facundo Thx! Yeah, I had seen that. Looks pretty straightforward


I did a little toy project using it, in case you want to see how the code looks


To be honest, I think the cljs/node.js combo could be a great way to get more people using clojure/clojurescript. There are so many people that already know/use javascript/node.js and being able to easily transition from that ecosystem would be a huge win. Yet another reason why is a Big Deal


@chrisbroome Agreed. Can always switch over to JVM if more power is needed


awesome. thanks for the link @kurt-o-sys


I'm still very new to the whole clj/cljs ecosystem and community, but I have to say I'm really impressed with how helpful everyone is.


@chrisbroome To extend the latter: if you have any issues, just give a shout 🙂


thanks! will do


If I have a string of clojurescript, say “(+ 2 (* 5 5))“, how could I “reduce” this to “(+ 2 25)“?


In other words, is there a way I can just run one step?


Not sure if this is the right channel to ask, I just need someone with in-depth knowledge of the clojurescript compiler