This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-12
Channels
- # alda (3)
- # beginners (17)
- # boot (157)
- # cider (15)
- # cljs-dev (30)
- # cljsjs (4)
- # cljsrn (5)
- # clojure (70)
- # clojure-austin (3)
- # clojure-canada (2)
- # clojure-colombia (1)
- # clojure-czech (1)
- # clojure-dev (27)
- # clojure-greece (34)
- # clojure-japan (6)
- # clojure-russia (114)
- # clojure-sg (3)
- # clojure-uk (8)
- # clojurescript (63)
- # cursive (9)
- # datomic (40)
- # devcards (11)
- # euroclojure (4)
- # events (8)
- # hoplon (61)
- # incanter (1)
- # instaparse (16)
- # jaunt (6)
- # jobs (6)
- # jobs-discuss (52)
- # ldnclj (1)
- # leiningen (2)
- # off-topic (3)
- # om (73)
- # onyx (101)
- # overtone (25)
- # re-frame (18)
- # reagent (6)
- # ring (7)
- # ring-swagger (36)
- # spacemacs (5)
- # sydney (1)
- # untangled (41)
- # yada (6)
Hi all! Can anyone point me to a solution to randomize the filename of my output .js build? In webpack you have a wonderful plugin to clone your HTML file and insert the reference to the randomized build file. This enables you to let clients cache the JS file, while keeping the html uncached so they see the reference to the new file as soon as it is published. I'm using Leiningen with cljsbuild.
I tried to insert :output-to (str "resources/public/js/app_nl_" (System/currentTimeMillis) ".js")
in my :compiler options, but that led to an error: 'java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol'
Ok, turns out my approach does work, I just needed to add a ~
in front of it, to prevent the Leiningen auto-quoting. So now I have to figure a way to add the randomized filename to my html. If anyone knows of an existing solution: still welcome!
You could set your file-name in leiningen/boot with defonce
and pass it to Clojure with :jvm-opts [(str "-DjavascriptPayloadName=" +javascriptPayloadName+)]
(or the equivalent in boot that I don't know off the top of my head)
Then do (System/getProperty "javascriptPayloadName")
to recover the name in your Clojure, or use cprop if you want a wrapper: https://github.com/tolitius/cprop
I am using cljs.build.api/build
to build my cljs-project programatically. I know about :warning-handlers
, but what about handling errors? It returns nil
error or no, and throws no exceptions. Anyone know?
you can catch exceptions if you like - we could be more consistent internally about how this is done
I'm probably doing something wrong then, because cljs.build.api/build
doesn't throw any exceptions.
I get this printed out: ERROR: JSC_CONSTANT_REASSIGNED_VALUE_ERROR. constant navigator assigned a value more than once.
, but it returns nil
with no exception.
we don’t integrate with those - we could - Closure supports custom error handling if I recall
what’s a good strategy for js interop where the offending js doesn’t return something (mutates passed-in value)?
for example…
(let [mutated (js->clj (.someJsFn js-obj (clj->js some-state-arg)))]
(merge some-state-arg mutated))
@lwhorton: I’d wrap it in a function that clones the object, then mutates it and returns it.
You’d need some form of deep clone. Maybe the library you’re using has one for that type?
I’m just having trouble with step 1, i.e. if I hand the js function a (clj->js {})
, I can’t capture the return value (there is none, it just mutates the map in place)… but I’ve lost reference to the map on the cljs side
I have a string in a variable v
and calling (int v)
spits compiler warning
"WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead"
trying the same thing in planck, works without warnings, I tried to read the source code in cljs.core and I have no idea where is that warning coming from
@darwin there are two places of code to read. The macro has ^::ana/numeric
meta on it.
@darwin: Wrote about the general concept here http://blog.fikesfarm.com/posts/2015-12-12-clojurescript-macro-functions.html
But, in short, it means you’d need to read the macro version if you are using it in operator position.
ok, thanks for the pointers, so I should figure out why the macro version is not called in my code (or the other thing)
@darwin: Always emitting warnings has been a challenge with bootstrap ClojureScript and Planck. But, on the surface, this appears to be one of those functions that requires numeric input.
relevant code here https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc#L2183
I'm trying to understand something about how macros work in cljs.... Looking at https://github.com/luxbock/bootstrap-cljs/blob/master/src/bootstrap_cljs/core.cljc, it generates a bunch of macros that create the cljs-friendly forms of the components, like (bootstrap/input ...)
.
What I don't get is what causes the #?(:clj ...)
code to get executed at all doing a cljs compile?
well, yeah, but as I understand reader conditionals, anything inside a #?(:clj ...)
form is only seen by the CLJ compiler, and NOT the CLJS compiler. is that not right?
curtosis: normally when you use macros in cljs code, the macros themselves are actually clojur
that’s normally not a problem because stndard cljs relies on having the closure compiler anyway, so you already have a JVM around
@curtosis: the clojurescript compiler will read clj code as a first pass and intern the macros. That preps the compiler environment for cljs
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc#L485
ahhh... that makes sense operationally. it perhaps just doesn't map cleanly to the mental model of the reader conditional. ("I'm compiling CLJS; ignore these")