Fork me on GitHub
#clojurescript
<
2016-07-20
>
ckarlsen10:07:36

"Internal change to the way the AST is represented, which results in much faster compilation, especially for projects with large files." <- changelog from latest closure compiler. Will probably benefit cljs?

martinklepsch12:07:18

Anyone seen ERROR: Not supported: class java.util.regex.Pattern coming out of CLJS compiler via com.cognitect.transit.impl.AbstractEmitter?

nha12:07:46

In clojurescript ? (I've used transit before and don't remember that otherwise)

anmonteiro12:07:08

@martinklepsch: I’m not sure if that’s the one, but I think I’ve seen something similar with a bad Guava transitive dep

martinklepsch12:07:24

(defn repro-breaks [{:keys [some-string extract]
                     :or {extract (fn [v] (re-seq #"(\S+)\s+" v))}}]
  (extract (str some-string " abc")))
This breaks it

martinklepsch12:07:43

I think it's not about using Transit but rather the compiler using transit for stuff (?)

martinklepsch12:07:25

hm, guava is at v19 which is what the compiler depends on

martinklepsch12:07:39

interestingly it doesn't happen when the pattern is defd

martinklepsch12:07:13

Even more minimal:

(defn x [{:keys [extract]
          :or {extract #"(\S+)\s+"}}])

martinklepsch12:07:16

Interestingly this works:

(fn [{:keys [extract]
        :or {extract #"(\S+)\s+"}}])

nha13:07:27

Ah for my sente problem it turns out destructuring im defmethod did not work as I expected it to. (or rather the data had a different shape than expected)

anmonteiro13:07:51

@martinklepsch: can repro here with CLJS master

lwhorton15:07:43

if I have an impure function I want to test, but it sits in another namespace, how do I go about that? I’ve looked at with-redefs, binding, and alter-var-root, but none seem to be able to handle /test/cljs/foo/foo_test.cljs trying to rebind something inside /src/cljs/foo/foo.cljs.

lwhorton15:07:27

(defn foo [x] (other-namespace/bar x))
How can I ‘mock out’ other-namespace/bar, basically?

lwhorton15:07:58

(without changing the signature — hence looking at binding as opposed to a more pure signature (defn foo [x impl] (impl x)))

joost-diepenmaat15:07:36

@lwhorton: you can use with-redefs to redefine a referred function

joost-diepenmaat15:07:24

at least in clojure/JVM

joost-diepenmaat15:07:07

(with-redefs [foo.foo/bar (fn [something something] …)] test-body) should work

joost-diepenmaat15:07:06

removed wrong example. the above works

joost-diepenmaat16:07:05

the usual reasons rebinding appears not to work is lazyness or async calls

joost-diepenmaat16:07:30

in other words, rebinding with with-redefs is only in effect while with-redefs has not returned

joost-diepenmaat16:07:41

and lazyness etc can confuse things there

lwhorton16:07:37

i see.. i could’ve sworn i tried that out but it was complaining about missing ns. I might have been missing foo. and just tyring foo/bar

johanatan18:07:12

anyone know why a compile involving a cljsjs dep would succeed with lein figwheel but fail with lein uberjar or lein run ?

johanatan18:07:35

this is the error:

ERROR - required "data_analytics_web.components.fixed_data_table" namespace never provided
goog.require('data_analytics_web.components.fixed_data_table');
^

johanatan18:07:43

[that should be provided by cljsjs]

johanatan18:07:51

[and works fine with lein figwheel]

johanatan18:07:13

oh, sorry. my bad

johanatan18:07:20

that's a local namespace

rohit18:07:42

@johanatan: yup. didn’t sound like a cljsjs issue.

johanatan18:07:46

i, perhaps unwisely, named it the same as the cljsjs one

rohit18:07:49

i’ve used that lib in the past

johanatan18:07:33

hmm, so the above namespace exists and should be getting compiled in

johanatan18:07:41

and works fine on figwheel

johanatan18:07:52

and pointers on tracking that down?

rohit18:07:57

@johanatan: is the error same as before your latest namespace name change?

johanatan18:07:08

i didn't make any change

johanatan18:07:25

i just recently added that namespace and the file containing it

rohit18:07:19

@johanatan: could it be a lein-cljsbuild compiler option issue?

johanatan18:07:34

does the directory structure need to match the namespace one?

rohit18:07:49

i don’t think so.

krchia19:07:55

has anyone tried using closure modules before?

krchia19:07:58

i don’t seem to be able to compile other modules i stated

johanatan19:07:32

btw, this issue occurs with the default re-frame template if you just add a subdirectory to the main src files location and name a namespace in it appropriately

rohit19:07:51

@johanatan: could you post your repo on gh or something?

johanatan19:07:03

i.e., I am pretty certain that this is either a: clojurescript, lein, cljsbuild, uberjar or re-frame default template project.clj bug

anmonteiro19:07:55

@johanatan: your folder needs to be called sub_namespace instead of sub-namespace

anmonteiro19:07:04

notice _ instead of -

johanatan19:07:28

i asked if folder structure mattered and @rohit said he didn't think so

johanatan19:07:00

that's not it though

johanatan19:07:08

in my original project the folder is named "components"

johanatan19:07:31

i will update the sub-namespace-bug with the preferred folder name and I think it will still repro

rohit19:07:08

@johanatan: i thought you meant folder structure as in the layout of directories and not the names

johanatan19:07:36

ok, looks like my original file name is "fixed-data-table.cljs" instead of "fixed_data_table.cljs"

johanatan19:07:41

I bet that's the problem

johanatan19:07:19

that was it. thx for the help @rohit & @anmonteiro !!

dfcarpenter21:07:36

Can anyone answer or point me to resources concerning if and when I should use deftype and defrecord in cljs?

darwin22:07:43

@dfcarpenter: deftype is lightweight (compiles to barebone js-type), defrecord is deftype with bunch of cljs protocols implemented on top of it

darwin22:07:24

if don’t need any of those stick with deftype, you can upgrade it to defrecord anytime later when the need arises