Fork me on GitHub
#clojurescript
<
2019-02-06
>
john01:02:44

I think I was over thinking it. I should be able to get the behavior I need just by allowing the user to nest my component in their hiccup forms

๐Ÿ‘ 5
eccentric J04:02:36

`ws` package must be installed to use `react-devtools`.
I get this warning even on a production build. Is there a way to have cljs built with things looking for process.env.NODE_ENV factored out?

eccentric J05:02:39

Hmm after thinking about it, probably more of a general node issue than cljs specific.

dominicm07:02:41

I thought there's a cljs flag to do that

dominicm07:02:14

:process-shim

dominicm07:02:46

I guess not :)

magnars12:02:42

After upgrading to ClojureScript "1.10.516" I get a warning when figwheel tries to reload my code: Can't take value of macro cljs.core/and, when the code looks like this:

(when (and beg end) ,,,)
but the warning goes away if I do this:
(let [both? (and beg end)]
      (when both? ,,,))
... could be something to do with the new type inference?

thheller12:02:16

looks like it. you should create a minimal repro and report it to Jira

magnars12:02:04

this only happens when figwheel tries to reload my code tho, not when it initially builds everything - so there's something weird going on for sure.

victorb13:02:51

The Day8/re-frame-debux lib mentions I should replace day8.re-frame/tracing with day8.re-frame/tracing-stubs when doing production builds (as the /tracing one might hurt dead-code elimination), but doesn't elaborate how to achieve this. Is there any tricks for replacing a lib just when doing a uberjar build but not otherwise?

manutter5113:02:49

Yes, hereโ€™s whatโ€™s in our project.clj file:

:profiles
  {:uberjar {:dependencies [[day8.re-frame/tracing-stubs "0.5.1"]]
             :omit-source true
            ,,, ;; etc
   :dev [:project/dev :profiles/dev]
   :project/dev {:dependencies [[day8.re-frame/re-frame-10x "0.3.3"]
                                [day8.re-frame/tracing "0.5.1"
                                ,,, ;; etc  

victorb13:02:29

@manutter51 many thanks for sharing that!

๐Ÿ‘ 5
restenb14:02:40

anybody using semantic-ui with reagent ?

john14:02:47

yogthos did something with it recently https://github.com/yogthos/semantic-ui-example

restenb14:02:11

it wants you to initialize certain components on the page with jQuery calls, which I can't get working

restenb14:02:13

i had the bright idea to just add the call I needed to :component-did-mount like so ^{:component-did-mount #(.dropdown (js/$ ".ui.dropdown"))} but apparently that's not correct either

djanus15:02:33

isn't it simpler to use semantic-ui-react instead? it doesn't require jQuery, so should have less footprint

john15:02:04

and it looks like there .dropdown probably just want's an element, so you could use a vanilla js .querySelectorAll, or goog.dom/getElementsByClass

restenb15:02:35

@dj942 yeah i've pretty much arrived at the same conclusion

restenb15:02:51

semantic-ui-react is jQuery free and there appears to be several straightforward wrappers for it on clojars, first and foremost cljsjs.semantic-ui-react

stathissideris16:02:21

semantic-ui-react works pretty well with reagent/re-frame

danielglauser16:02:51

Just hit up against https://dev.clojure.org/jira/browse/CRRBV-15 when trying to run some doo tests in one of our cljs projects. Does anyone happen to know a workaround?

Alex Miller (Clojure team)22:02:00

Michal fixed and cut a new 0.0.14 release today

Alex Miller (Clojure team)16:02:52

if someone can supply a patch, happy to help get it applied/released

5
Dustin Getz17:02:17

Can a ClojureScript defmulti be queried? VM1169:1 Uncaught TypeError: cljs.core.methods is not a function

Dustin Getz17:02:00

It can, the name is munged, my bad cljs.core.methods$

dominicm19:02:43

is it possible to access javascript equality in cljs?

john21:02:08

Yeah, apparently all js fns return undefined if nothing else

john19:02:54

I think identical? will work.

dominicm20:02:47

okay, which leads me onto my next question. Is returning js/undefined the only way to emulate a function without a return?

jstaab20:02:01

I seem to have found a bug, but I'm really not sure where to even start (and I really don't have time right now), but does anyone ever lose global vars inside a deftest block? The following code:

(prn 1 validate!)
(deftest test-example
  (prn 2 validate!)
  ...)
prints
1 #object[consigncloud$policy$pos$validate$validate_BANG_]

Testing my.test.ns
2 nil

jstaab20:02:25

I'm using shadow-cljs with a custom test-runner namespace if that matters

jstaab20:02:49

Although I'm really just swapping out the reporter, and I haven't had a problem like this in a while. Odds are I've made some mistake

thheller20:02:39

try (js/console.log ...) if it really goes away or your printer/reporter maybe just gets confused

jstaab20:02:23

Ha it gives me:

nil
undefined

jstaab20:02:45

but if I add (def validate! validate!) at the root level, it works

thheller20:02:03

that is not valid

thheller20:02:10

that will cause a self reference

jstaab20:02:17

I take that back, (def v! validate!) works

jstaab20:02:39

I'm importing validate! from another namespace, where it's just defined using defn

thheller20:02:01

then use the alias/validate! ๐Ÿ˜‰

jstaab20:02:07

When I (prn v!) inside the test it gives me

#object[consigncloud$policy$pos$validate$validate_BANG_]
[Function: consigncloud$policy$pos$validate$validate_BANG_]

jstaab20:02:50

What's alias?

jstaab20:02:02

Oh you mean v!?

thheller20:02:07

(:require [some.thing :as alias])

jstaab20:02:30

(prn v/validate!)

jstaab20:02:37

gives me nil still

jstaab20:02:49

oh wait I misread your require

jstaab20:02:21

nevermind, that still didn't work

jstaab20:02:29

is there a builtin I'm nuking?

thheller20:02:55

I'm lost and don't know what you are doing anymore ๐Ÿ˜›

jstaab20:02:03

ha sorry, let me recap

jstaab20:02:14

(ns x (:require [y :refer [validate!]])
(def v! validate!)
(prn v! validate!) ;; => function, function
(deftest test-x
  (prn v! validate!) ;; => function, nil
  )

jstaab20:02:43

edited for succinctness

thheller20:02:06

works perfectly fine for me in a test build using exactly that setup

jstaab20:02:20

My test case is very much tied together with other code, if I continue to have the problem I'll try to put together an isolated test case. Unfortunately I've got a time crunch, so I'll use the redefinition trick for now

thheller20:02:10

do you may run other tests that with with-redefs or other stuff?

thheller20:02:38

something that may mess up the tests when they actually execute? since the initial prints all run when the code is loaded

thheller20:02:59

so if something messes with the namespace objects after they have been loaded that will break stuff

jstaab20:02:11

Not much, I'm not super good at namespace/var manipulation. I do use binding with a different var from the same namespace, and elsewhere in the calling namespace I use ns-publics for an unrelated ns

jstaab20:02:36

That is, I bind a var from the validate! namespace

jstaab20:02:47

That's all done at load time

jstaab20:02:06

I think before the tests are registered

thheller20:02:12

after the tests are done

thheller20:02:29

try checking the state of the code in the JS console

thheller20:02:42

something likely just got renamed somehow

jstaab20:02:01

Ok, I'll give it a shot, thanks for your help

jstaab20:02:11

And I'll try to put a test case together too

thheller20:02:16

try running only that test ns and nothing else

john21:02:08

Yeah, apparently all js fns return undefined if nothing else

jstaab21:02:35

@thheller I tracked down the problem; I was in the midst of a refactor, and a namespace was clashing with a var named the same as the last segment of that namespace exported from another namespace with the same first few segments. To make that concrete, the warning I got eventually was: Namespace consigncloud.policy.pos.validate clashes with var consigncloud.policy.pos/validate. So it was a weird thing I was doing. But I did experience some buggy behavior, first, I wasn't getting that warning until I had removed half my source code, so I'm not sure why but something was suppressing it. Second, I only experienced the bug because of what I assume are internals of dependency resolution order; I removed a completely unrelated file and my code started working. Anyhow, I'm good to go, is there anywhere I might report that but? I'm not sure I can produce a test case for it since it involves a lot of my code. Definitely one of those hard-earned pieces of wisdom that I'll remember though ๐Ÿ˜…

thheller21:02:38

hehe yeah those things can be tricky. I wish namespace weren't built like that but its too late to change that now ๐Ÿ˜ž

thheller21:02:22

not sure why you wouldn't get the warning immediately but I suppose compilation order matters for that

jstaab21:02:41

Yeah, it's very weird that they would clash like that

Braden Shepherdson22:02:05

so I finally succeeded in getting Clojurescript to build under Bazel, with an external Closure library and so on.

Braden Shepherdson22:02:37

but I'm getting double-inclusion, and I'm possibly grabbing the wrong files. I want cljs to output everything but the Closure core bits

Braden Shepherdson22:02:52

I can find the files with just my own code, but they depend on the cljs core library.

Braden Shepherdson22:02:18

oh, cljs.core is a Closure library; I can probably include those separately.

thheller22:02:18

is that a question? CLJS compiled code always depends on cljs.core since the collections and stuff live there

Braden Shepherdson22:02:46

I discovered more files than I thought were generated; I think I grabbed a "big" file instead of the "small" one.

thheller22:02:29

cljs/core.js is pretty big 1.3mb or so unoptimized

Braden Shepherdson22:02:09

yeah. the objective here is to let Bazel do the combining and compilation; I want just my code as a Closure library with goog.require statements.

Braden Shepherdson22:02:40

linking in the goog.base and cljs.core libraries is done externally, here.

Braden Shepherdson22:02:04

I realize this is against the grain of the usual CLJS build style; but it's more important to fit with the much larger grain of Google's build system.

thheller22:02:28

you shouldn't combine output from different compiles that may cause issues when they came from different versions

thheller22:02:02

but otherwise you can take the :none output just fine and include it

thheller22:02:24

not sure about bazel but the source files act like any other closure library source

Braden Shepherdson22:02:44

yeah, it's Bazel that's causing difficulty here

Braden Shepherdson22:02:58

I've got it grabbing the right, standalone files now.

Braden Shepherdson22:02:25

the cljs.main run produces both the simple JS files and bigger ones that include cljs.core and goog.base already.

thheller22:02:53

you only need to run :optimizations :none if you are going to process them anyways. no need to run :simple

Braden Shepherdson22:02:42

it was several weeks ago I first took a crack at this; I thought the :none output didn't have the goog.requires?

Braden Shepherdson22:02:46

I guess I can try it

thheller22:02:01

:simple doesn't have them, :none does.