Fork me on GitHub
#clojurescript
<
2017-09-26
>
jimmy03:09:21

hi guys, cljsbuild hangs while compiling a file, is there any good way to debug this?

dnolen05:09:15

@nxqd there are some edge cases around circular deps (which aren’t allowed anyway) and :parallel-build

jimmy10:09:09

yeah, it was circular deps. Thanks for response.

amit588106:09:37

want to add npn kind of search in clojurescript

karlstefan07:09:05

Question about generic components in re-frame. How do you guys organize them in the namespaces?

karlstefan07:09:02

In react I'm used to 'smart' and 'dumb' components, so this would be a dumb comonent, i.e. is not connected to a datasource it self, but receieves everything form its parent.

mccraigmccraig07:09:32

@karlstefan (there is also #re-frame ) generally you put the component in a namespace with db/events/subs/views sub-namespaces... separating out like that makes for clean dependency resolution even across clj/cljs boundaries (e.g. so you can use re-frame-test to test your event-handlers and subs from clj) https://github.com/Day8/re-frame/wiki/A-Larger-App

hkjels12:09:14

(re-pattern (str "(?iu)" substr)) is the case-insensitive modifier broken in ClojureScript?

darwin12:09:11

@hkjels cljs regexps are javascript regexps, don't expect java regexp semantics there

hkjels12:09:55

@darwin actually, replacing re-pattern with js/RegExp. yields the same result, so I’m now looking into str/replace

darwin12:09:41

@hkjels I'm not aware of "(?iu)" regexp modifier in javascript

hkjels12:09:55

(js/RegExp. substr "ig") unicode is not the important bit here, it’s the case-sensitivity that’s the issue ATM

darwin12:09:25

yep, that should work

hkjels12:09:12

so, using (.replace s pattern "replacement") worked which leaves me thinking that something is broken with str/replace

darwin12:09:56

show us the code 🙂

hkjels12:09:20

OK, just a sec

hkjels13:09:35

would be a lot tighter if I didn’t have to separate based on clj/cljs

hkjels13:09:38

ahh, util/=i just does (apply = (map str/lower-case args)) basically

darwin13:09:00

well, I expected one-liner in REPL which would demonstrate how str/replace does not work for your input

dominicm13:09:17

@hkjels I think it's that clojurescript regex doesn't support the global modifier, as it's stateful, which breaks some cljs expectations

dominicm13:09:02

(re-matches #"(?i)fo\w" "fOb") this works for example

hkjels13:09:48

Yeah, but I expect the same to fail with str/replace

dominicm13:09:08

If I use (?g) my compilation outright fails

dominicm13:09:52

oh, clojure.string/replace for cljs, makes your regex global for you :thumbsup:

dominicm13:09:10

So you only need i, not g

hkjels13:09:26

yeah, I just have i. Still fails

dominicm13:09:58

(clojure.string/replace "aaaafOBaaaaa" #"(?i)fob" "toe")

dominicm13:09:51

^ works for me

hkjels13:09:23

what version of clojurescript?

dominicm13:09:45

@hkjels is the problem that you're using (.replace) for cljs, not string/replace

hkjels13:09:27

just pasted your snippet into http://clojurescript.io/ it fails as well

hkjels13:09:42

@dominicm The snippet I posted works, I just don’t think it should be necessary to use separate code for cljs and clj in this case

dominicm13:09:07

the source on http://clojurescript.io for clojure.string/replace is the same as on 1.9.908

hkjels13:09:32

@dominicm then I don’t get why it worked for you

darwin13:09:16

in Chrome devtools: clojure.string.replace.call(null,"aaaafOBaaaaa",/fob/i,"toe") => "aaaafOBaaaaa" but "aaaafoBaaaaa".replace(/fob/i,"toe") => "aaaatoeaaaaa"

darwin13:09:51

looks like a different behaviour when .call is generated

darwin13:09:24

wait, sorry, forget it 🙂

dominicm13:09:49

Figured it out

dominicm13:09:01

replace-all, which replace delegates to, seems to have had some changes.

dominicm13:09:43

1.9.908 is the latest stable cljs afaik

hkjels13:09:35

Ahh, OK.. Great! I see that replace-first works

dominicm13:09:12

@hkjels btw, if the input to your function is always a normal string (user input?) then it will break if the user types in . (unless this is intentional)

hkjels13:09:12

that’s not intentional

hkjels13:09:24

I’ll escape those

dominicm14:09:32

@hkjels it might be better to use split, which can work on a normal string afaict

dominicm14:09:44

generally speaking, building a regex out of user input = always unhappy

dominicm14:09:13

there are java & closure functions for escaping input for a regex though

borkdude14:09:31

nice surprise, destructuring also works for js arrays?

pesterhazy14:09:15

often things also work the other way around

mfikes14:09:35

IIRC, that works because something like (get #js [0 2 3] 1) works

pesterhazy14:09:55

i.e. a lot of javascript functions, like js/Promise.all transparently accept a PersistentVector instead of an array

pesterhazy14:09:43

I'm guessing because the interface they expect is really an iterable, not an array?

pesterhazy14:09:02

JS duck typing is confusing to me 🙂

raspasov15:09:56

re: destructuring… a few days ago I was wondering if I can get ClojureScript destructuring to “work” on JS map-like objects but I don’t think it does 🙂

raspasov15:09:05

(probably for good reasons)

pesterhazy15:09:43

no it doesn't work on plain old JS objects

johnnyillinois21:09:43

Hello! Is anyone using re-frame plus bidi in a cljs application? I have a implementation question about routing

darwin21:09:04

@johnnyillinois maybe try to ask in #re-frame

davclark21:09:48

This seems like a really basic question, but I can't find docs anywhere. What is the order of execution for compiled cljs? I am including another library via a script tag and want to make sure it's loaded first. If I have only one such library, I can use onload in the script tag on an extern'd cljs function... but that breaks if there are multiple dependencies. Is there a more idiomatic way?

davclark21:09:54

After hours of reading - shortly after writing this, I realized that the best approach is probably to manual specify order in my HTML file (which guarantees order of execution).

davclark21:09:29

But I'd be happy for a pointer on docs about this problem in general in cljs!

darwin21:09:41

@davclark correct, you cannot specify total namespace ordering, they are ordered based on dependencies which gives only partial ordering (AFAIK)

darwin22:09:08

this is what I recommended in cljs-devtools (prior introduction of :preloads): https://github.com/binaryage/cljs-devtools/blob/master/docs/installation.md#install-it-manually

darwin22:09:34

the goal is to load cljs-devtools first, before any other code

roman01la22:09:52

Is it supported to refer to a var in a scoped NPM package by its fully qualified name?

bendlas23:09:19

is ##NaN support in the works for cljs yet?

anmonteiro23:09:18

@bendlas I think it’s in master

anmonteiro23:09:50

just need a tools.reader bump now I think

bendlas23:09:48

@anmonteiro great! right now it's breaking data.xml's test-matrix for 1.9.0-beta1 but I suppose it will be an easy fix, on the next cljs release ..

anmonteiro23:09:15

should just be a matter of bumping CLJS