Fork me on GitHub

there is but not sure if there are better solutions out there

Jordan Yee01:08:41

Does anyone know a good way to add a version number to the output files of compiled cljs? Instead of always outputting myproj.js, I'm trying to get something like myproj.js?v=1234 to prevent caching errors. Ideally the version number would be changed each time the file is re-compiled.

Oliver George05:08:53

Can someone recommend a way to avoid my different build profiles becoming a mess please. There are three variables involved: platform (ios or android), optimisation (none or simple) and system (dev, test or prod).


Since project.clj is clojure - I suppose you could write code to generate these profiles?

Oliver George05:08:11

The system matters because it requires some :closure-defines to configure services.

Oliver George05:08:55

Figwheel has limited awareness of lein profiles so I'd need 6 profiles each with two builds (ios and android).

Oliver George05:08:14

I'd be happy to ditch lein in favour of clj and deps.edn. That would require a build script which generates the build configuration which is a little messy but works. I'm a bit muddled about how works with source paths (it takes nil or one path but I have many source paths). My source paths differ for development (none) and production (simple) builds - perhaps I should be using a deps.edn aliases to control source paths.

Oliver George07:08:54

The deps.edn approach is looking pretty good. I can mix and match with -co like this:

clj -A:dev -m cljs.main -co compiler/ios-none.edn -co compiler/testserver.edn -c

Oliver George07:08:12

Sounds like clj -m figwheel.main is a thing too. Would be nice if it slotted in without too much additional baggage.


@olivergeorge figwheel.main can help you with this

Karol Wójcik13:08:50

Hi guys. Got some macro which uses the module imported to file in which that macro exists. The problem is that the macro instead of using the module from the macro file uses the module from the file in which is used.

(defmacro with-memory-monitor
  [filename body]
  `(let [should-close# (tools/register-close)
         writable-stream# (.createWriteStream nm/fs ~filename (cljs.core/clj->js {:encoding "utf-8"}))]


     (.setInterval nm/timers
                   (fn []
                     (if-not @should-close#
                       (.write writable-stream# (str (.-heapUsed (.memoryUsage js/process))))
                       (.end writable-stream#)))
For instance nm and tools should be taken from the file in which macro is defined

Karol Wójcik13:08:10

How can I achieve that?


It seems to me you should be able to unescape those bits and then they will be resolved in the macro-defining namespace.


Wait, that makes no sense. 😞


@kwcharllie379 you should make it and arg to the macro


to be clear I'm saying not nm but rather the nm/timers should be an arg

Karol Wójcik13:08:51

ok so the macro is unable to use the modules imported in macro file


in the file where it is used


I’ve been meaning to write a post on a pattern for getting macros to use runtime functions defined in “their namespace”. So far I only have a simple repo that illustrates the idea:


@mfikes the link doesn't work


Thanks. Fixed. (It was private.)

Karol Wójcik14:08:38

Well that's not a problem to use the module from the file in which the macro is imported to. The problem is to use the some moduleA in a file in which macro is defined.


@kwcharllie379 In the example linked above, the producer.core/reverse-lookup macro uses producer.core/inverse*. Does that fall into your moduleA category?


yeah, mistated that

Karol Wójcik14:08:50

Yes. OK I think I get this. It's possible here because you got two files named core 😜


Right, the entire pattern is based on implicit macro loading (per (doc ns)), but you can see that producer.core/reverse-lookup' uses a function from an entirely different namespace as well


TL;DR: The producer.core/reverse-lookup' macro illustrates how you can arrange to use code from a 3rd namespace. (In the example that namespace is clojure.set)


I suspect you’d like with-memory-monitor to use stuff from the nm and tools namespaces. To do that their references would be qualified and the *.cljs file associated with with-memory-monitor would be the one to :require them.


I wanted to give something back to you all. Thank you. All comments are welcome.


ooh, I like that handler chain parameter idea


different sort of ergonomic their


Thank you! 😇


Do you have any suggestion for it ?


Haven't looked into it much. But any reason not to just let that fn take a variable number of args and just add each extra are to a chain internally? Or were you planning to extend the signature with other things?


Yeah. I have so many ideas but I need feedback. I want to work on this library. It looks so simple when you look at it first, but it has an important domain. This community helped me so much, I owe you guys.


is there a way to represent ##NaN as a literal in clojurescript?


##NaN is a literal


That’s the usual way… but what do you really mean?

Karol Wójcik14:08:49

Yes so basically I would have to create macros.cljs in which I import this nm and tools and everything should work.

Karol Wójcik14:08:56

Thank you very much @mfikes


Yeah, and be sure to qualify things (presuming nm and tools might be aliases given they are single-segment symbols)

❤️ 4

oh, yes it is


so (js/isNaN ##NaN) should work?

👍 8

never mind


just stale buffers

Karol Wójcik15:08:08

It works! thank you @mfikes you’re Clojure/script magician


so, in garden

(ns css-playground.styles
  (:require [garden.def :refer [defstyles defcssfn]]
            [garden.units :refer [px em]]))

:padding [(em 5.625) (em 12.5) (em 12.5) 0]

compiles to
padding: 5.625em, 12.5em, 12.5em, 0;
is there any way (other than just doing a string instead of data) to specify something that compiles to padding: 5.625em 12.5em 12.5em 0;?


the commas are screwin me


you wrap it in another list


:padding [[(em 5.625) (em 12.5) (em 12.5) 0]]


lol yeah, untested, I think that's how


where'd you find that trick?? 😂 it totally works!


I ran into the same issue a long time ago 😛


hahaha, that's awesome. there is so much undocumented magic in garden its crazy


oooh, you got me... I didn't read that whole page 😅


thanks, aisamu!

🙂 4
🤓 4

thank god for clojurians


Agreed, I feel like a good blog post, or maybe some more stuff added to the wiki would help a lot


much gratitude, benzap


In this space recently, hearty skepticism was expressed as to whether I might have anything new to offer on Web app development. Very understandable. I have done my best to write it up, and would be interested in critical feedback.

👍 4

You should start with a rationale. That would help readers to understand what problem you're trying to solve and what is your value proposition compared to other cell-based dataflow engines.


also, you should define what HLL is


the code snippet in paragraph A tells B is weird


That is part one. It links to a denser part two on which I am still hacking. Beware. 😱


Neat, i'll give it a read


I have an app in cljs which compiled within a few dozens of seconds, which is fine. However, now, it takes a very long time, if it ever succeeds. Even after reverting my last changes, compilation seems to take forever. Is there a way to 'debug'/profile compilation?


:verbose true :compiler-stats true


shadow-cljs watch app
[...]shadow-cljs - config: [...]/shadow-cljs.edn  cli version: 2.4.
28  node: v8.11.3                                                                                                                                                                                                                            
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Aug 10, 2018 9:24:23 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 10, 2018 9:24:23 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/home/storage/mvn/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Aug 10, 2018 9:24:23 PM invoke
INFO: duplicate resource day8/re_frame/tracing.cljc on classpath, using jar:file:/home/storage/mvn/repository/day8/re-frame/tracing/0.5.1/tracing-0.5.1.jar!/day8/re_frame/tracing.cljc over jar:file:/home/storage/mvn/repository/day8/re-fra
shadow-cljs - HTTP server for :app available at 
shadow-cljs - server version: 2.4.28
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 35966
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
Aug 10, 2018 9:24:29 PM$NamedPass process
WARNING: Skipping pass rewriteGoogJsImports
Aug 10, 2018 9:24:29 PM$NamedPass process
INFO: pass supports: [ES3 keywords as identifiers, getters, reserved words as properties, setters, string continuation, trailing comma, array pattern rest, arrow function, binary literal, block-scoped function declaration, class, computed
 property, [...] operator (**), async function, trailing comma in param list]                                                                                                                              
current AST contains: [ES3 keywords as identifiers, getters, [...], octal literal, RegExp flag 'u', RegExp flag 'y', rest parameter, spread exp
ression, super, template literal, modules, exponent operator (**), async function, trailing comma in param list, object literals with spread, object pattern rest]                                                                           
Aug 10, 2018 9:24:41 PM println
WARNING: node_modules/highlight.js/lib/languages/tp.js:14: WARNING - String continuations are not recommended. See 

Aug 10, 2018 9:24:41 PM printSummary
WARNING: 0 error(s), 1 warning(s)
the warnings are there already quite some time. They don't seem to be harmful.


@kurt-o-sys oh shadow, you probably want to ask in the #shadow-cljs channel


right, thx...


@dnolen what’s the current state of om-next?


Thanks, @benzap. And thanks to @mikethompson for the pep talk as I waded into the task. I even learned I could embed raw HTML in readmes from his doc. 🙂


@pvillegas12 it exists and works in it’s current form but I don’t really have much time these days to steward it - ClojureScript demands and all


@pvillegas12 there’s also pretty nifty alternatives - Fulcro


and of course the idea is bigger than the lib - you can adopt the patterns a la carte


Are there any big departures between fulcro and om-next? I’m evaluating between using either for a new project


fulcro I think is more flexible / dynamic now - I didn’t have time to sort that out in om-next

👍 4