This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-20
Channels
- # aleph (4)
- # beginners (47)
- # boot (22)
- # cider (7)
- # clara (1)
- # cljs-dev (8)
- # cljsrn (21)
- # clojure (180)
- # clojure-argentina (13)
- # clojure-gamedev (1)
- # clojure-italy (5)
- # clojure-poland (4)
- # clojure-russia (17)
- # clojure-spec (19)
- # clojure-uk (33)
- # clojurescript (107)
- # cursive (61)
- # data-science (1)
- # datomic (7)
- # emacs (69)
- # euroclojure (1)
- # graphql (1)
- # hoplon (11)
- # immutant (43)
- # jobs (1)
- # leiningen (3)
- # off-topic (5)
- # om (10)
- # onyx (2)
- # parinfer (52)
- # pedestal (11)
- # re-frame (31)
- # reagent (23)
- # ring-swagger (3)
- # schema (2)
- # specter (7)
- # unrepl (9)
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 ?
@solve-calc.com 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?
@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'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?
@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
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
@mrchance I got the idea from https://anmonteiro.com/2017/03/requiring-node-js-modules-from-clojurescript-namespaces/
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 😉
@oskarkv in case you are interested I added a quick electron example for shadow-cljs https://github.com/thheller/shadow-cljs-examples/tree/master/electron
the support for requiring node modules is a bit more solid there and should work for the main and renderer
and getting a lot of warnings like WARNING: JSC_BAD_JSDOC_ANNOTATION. Parse error. illegal use of unknown JSDoc tag "grep";
@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?
a cljs project
Normally, stuff in out
is reused by the compiler for performance reasons (https://clojurescript.org/reference/compiler-options#cache-analysis)
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
on both?
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
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
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
omg don’t get my hopes up
@robert-stuttaford One thing to look out for is that all of the :main
s 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)
thanks fellas!
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 …
trying to get https://github.com/benrlodge/react-simplemde-editor working with :npm-deps
@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 om.next (other than their respective docs)?
found a bit here https://news.ycombinator.com/item?id=13379609
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: https://github.com/reagent-project/reagent/issues/296
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
good to know, @kurt-o-sys
Yeah, just do it. You'll see, it's a breeze.
@fedreg take a look at macchiato https://macchiato-framework.github.io/
I did a little toy project using it, in case you want to see how the code looks https://cljsbin-bkhgroqzwe.now.sh/
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 https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules is a Big Deal ™
https://specious.github.io/blog/2016/12/07/Starting-a-NodeJS-app-with-ClojureScript-and-Boot/ did it for me.
@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