Fork me on GitHub
#clojurescript
<
2017-10-03
>
anmonteiro00:10:23

I’m saying you wanna add that map to the foreign lib definition

anmonteiro00:10:25

as per the blog post

ag00:10:55

oh, I still need to use cljsjs package, right?

anmonteiro00:10:40

your generated package will be something like:

{:file "/path/to/enzyme.bundled.js"
 :provides ["cljsjs.enzyme"]}

anmonteiro00:10:07

but I’m saying you want it to be:

{:file "/path/to/enzyme.bundled.js"
:provides ["cljsjs.enzyme"]
 :global-exports '{cljsjs.enzyme enzyme}}

ag00:10:13

so that's my initial question, can I do global-exports thing in the package itself, so whoever uses the package can just require it idiomaticallly?

anmonteiro00:10:20

I would ask @juhoteperi how to accomplish that

anmonteiro00:10:42

he implemented most of the global-exports functionality in the compiler

ag00:10:36

you know what, I think I have found a few cljsjs packages that include global export thingy

madstap00:10:24

On the clojurescript github it says that [org.clojure/clojurescript "1.9.946"] is the latest version, but it can't seem to find it in maven central. Is this just me or?

anmonteiro00:10:20

I think David is looking into it

manuel07:10:17

Hi everybody. A question regarding :foreign-libs. I am trying to add this library to my project: http://d3-legend.susielu.com/ I added this in my project.clj:

:foreign-libs [{:file "foreign-libs/d3-legend.js"
                                :file-min "foreign-libs/d3-legend.min.js"
                                :provides ["d3-svg-legend"]}]
From Figwheel REPL, this is what I get:
dev:cljs.user=> (require '[d3-svg-legend])
nil
dev:cljs.user=> (js/d3.legendColor)   
#object[TypeError TypeError: d3.legendColor is not a function]
nil
dev:cljs.user=> (-> js/d3.legendColor (.useClass true))
#object[TypeError TypeError: Cannot read property 'useClass' of undefined]
nil
Any tips?

manuel08:10:11

I have also tried using the file URLs in :file:

:foreign-libs [{:file ""
                                :file-min ""
                                :provides ["d3-svg-legend"]}]
dev:cljs.user=> (require '[d3-svg-legend])
nil
dev:cljs.user=> js/d3.legendColor
nil
dev:cljs.user=> (js/d3.legendColor)
#object[TypeError TypeError: d3.legendColor is not a function]
nil

danielstockton09:10:02

Is there a max size after which a map (in an atom) will no longer allow assoc?

rauh09:10:02

@danielstockton Nope, unless your run out of memory

danielstockton09:10:47

@rauh that's what I would have thought. Will it just fail silently in that case or i'll notice the performance of the browser tab seriously degrade?

danielstockton09:10:54

I keep associng and subsequent get tells me it's nil. Haven't ruled out i'm not doing something stupid yet.

rauh09:10:02

@danielstockton Your browser tab will likely just chrash

rauh09:10:26

Your error is probably somewhere in the programming logic

oliy11:10:51

Hi, does anyone know the reason that cljs publishes its own packaged version of Google closure, rather than just depending on the one in maven? What's the difference?

dnolen11:10:19

@oliy we package our own version of Google Closure Library not Compiler

dnolen11:10:34

we may eventually do the later, but we haven’t taken that step yet

mseddon11:10:04

is it identical to something IN maven, or modified in some way?

oliy11:10:07

@dnolen oh right so the closure library is not in maven, only the compiler is, and that's why it's packaged so that lein can get to it?

oliy11:10:46

So would it be possible with the new npm deps to pull closure from npm instead?

dnolen11:10:54

@oliy no, the source would have to respect npm resolution

dnolen11:10:00

Google Closure Library doesn’t

dnolen11:10:37

@mseddon GCL is not in Maven at all

mseddon11:10:55

oh! I hadn't realised. Okay that makes sense, thanks.

dfcarpenter14:10:16

I have a build question. Addy Osmani from google released this helpful guide on image optimization https://images.guide/. For my project I would like to integrate some of the tools mentioned into my production build pipeline. What would be a recommended way to do this?

a1316:10:42

Hi ! Is there a simple way to use a local editor with a remote figwheel+nrepl? I can connect to repl, but hot reloading doesn't work (since files are changing on a local machine).

spinningtopsofdoom16:10:53

You could try using this to sync the local and remote file systems https://github.com/axkibe/lsyncd

a1316:10:59

I see, thanks

chris17:10:53

depending on your platform, I'd likely ssh into the server or use TRAMP or something

a1317:10:37

tramp is an option too, yes, but I think If there is a way to work like I usually deal with Clojure - run remote repl, connect to it and make changes locally

a1317:10:40

thanks, anyway!

levitanong18:10:51

[elided]clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljs [line 988, col 14] No reader function for tag Inf. Got this on the new 1.9.946, tried a google search, seems like there’s no reference to this. On boot 2.7.2 and clojure 1.9.0-beta1. I will work on getting a minimal repro, but I’m jumping the gun hoping that maybe the source of the problem will be readily apparent to someone before I get that repro out.

mfikes18:10:17

@levitanong It is worth checking whether you have explicitly set your tools.reader dep to something lower than what ClojureScript 1.9.946 wants (tools.reader 1.1.0)

levitanong18:10:52

@mfikes looks like that was it! Thanks so much!!

bhauman18:10:41

@darwin hey, did you bring up that quoting thing yesterday because you actually tried to use eval-fn?

darwin18:10:58

@bhauman did you see the commit message in the dirac repo? specifying (fn [] :something) in config data would not bubble into cljs properly, that fn would get converted to clojure fn before it gets passed into cljs as data

darwin18:10:40

I discovered it, because I needed to specify some cljs fn handlers in config

bhauman18:10:02

yeah they are supposed to be vars

bhauman18:10:07

or symbols

bhauman18:10:50

arbitrary code is really tough, a var or symbol ensures that the var or symbol is compiled in an environment that can handle it, also I cheat and turn the var or symbol into a js call so that I don't have to require the namespaces of each hook which is impossible to do in a preload library

darwin18:10:05

ah, I see what you mean, didn't think about needing to require stuff in my handler

darwin18:10:37

but before I made that quoting change it was wrong, because the code wasn't emitted as-was in the config

bhauman19:10:51

@darwin you are talking about the fn? I made a mistake and didn't handle eval-fn correctly

bhauman19:10:14

I'll fix it and the eval-fn should work for symbols

bhauman19:10:27

but not for arbitrary code

darwin19:10:27

I don't understand, I don't remember the details of your :eval-fn, my point was that having config as data, containing something like {:some-key (fn [] :something)} would not be emitted into cljs as-is (with a macro which simply returns this data)

darwin19:10:55

the fn part would be converted to clojure fn, unless quoted

bhauman19:10:02

OK I get that but this is a particular situation

darwin19:10:02

or maybe I am missing something?

bhauman19:10:59

the figwheel-options config only has the function hooks that could possibly cause a problem here and they have to be symbols/strings

bhauman19:10:45

since I handle them as a special case I am "eliminating" the possibility of not passing data across from the macro

bhauman19:10:51

but I get your point, its just a bit tough to fix because I'm generating these wrapper functions that detect the existence of the function on the client side

bhauman19:10:29

its doable though but super ugly

darwin19:10:33

ok, fine, I just wanted you to think about that, because that was unexpected behaviour for me, I still don't understand why it behaves like that

darwin19:10:55

I would expect a data structure returned from a macro to "appear" in cljs code as-is

darwin19:10:38

but when I think about it more, that data structure is in fact a clojure data structure, not cljs data structure, so not everything can be represented in cljs

darwin19:10:40

for example

bhauman19:10:13

if you want me to explain it completely I will, just not sure that you want need that

bhauman19:10:51

but it comes down to the fact that I'm managing the fact that users are passing in vars that may or may not exist when the code is loading

bhauman19:10:02

and may or may not exist at all

bhauman19:10:16

and this causes hard to solve problems at runtime

darwin19:10:25

I understand your problem with requires, but that is completely unrelated issue to what I raised originally

bhauman19:10:42

I'm not talking about requires right now

genekim19:10:22

I love Lambda Island tutorials. I recently tried to replicate getting test.cljs working, from Episode 33… Did git clone , and then lein cljsbuild once test, and got this error. Anyone have any ideas on how to get this running? Thank you!!! Relevant error line is:

Caused by: clojure.lang.ExceptionInfo: No such namespace: doo.runner, could not locate doo/runner.cljs, doo/runner.cljc, or Closure namespace "doo.runner" in file /Users/genekim/src.local/tmp/ep33testcljs/test/testcljs/test_runner.cljs {:tag :cljs/analysis-error}
Full console error log following in snippet…

noisesmith19:10:24

I assume the project.clj references the doo plugin?

genekim19:10:40

Yes? https://github.com/lambdaisland/ep33testcljs/blob/master/project.clj @noisesmith

:plugins [[lein-figwheel "0.5.11"]
            [lein-cljsbuild "1.1.6"]
            [lein-doo "0.1.7"]]

noisesmith20:10:00

the other suggestion I can make is see if you have any cached / stale compiled artifacts from other builds that make the test task fail - I don’t know doo well enough to help beyond that though

genekim20:10:34

@noisesmith Thanks for the suggestion — I did the git clone into a totally new directory. Do you mean doing something global, like deleting the ~/.m2 directory or something like that?

noisesmith20:10:53

oh no, removing m2 should never be needed

genekim20:10:27

Roger that — removing hands from keyboards. 🙂

noisesmith20:10:12

the only time removing m2 would help is if some project(s) deployed a new artifact with the same version number as a previous one, which is explicitly the wrong thing

noisesmith20:10:48

occasionally an alpha lib with a lazy or incompetent maintainer does it, but nothing you would actually want to use on purpose

noisesmith20:10:19

so if removing m2 fixed the problem, the real solution is not using the lib that required you to do that

lilactown20:10:00

are js->clj and clj->js actual inverses?

lilactown20:10:40

as in, would a JSON obj passed into (clj->js (js->clj ...)) always be of the same form?

thheller20:10:42

@lilactown not quite, I wouldn’t count on it

thheller20:10:49

should be in most cases but is not guaranteed

lilactown20:10:07

annoyingly cljs-http automatically converts json response to clojure 😩

dpsutton20:10:12

open an issue. seems like it would be easy to fix. you could do a dynamic var in utils/parse-json, you could make that a config option passed in with a default, all kinds of ways. take a stab at it and then find out which he prefers?

lilactown20:10:43

there's currently an open issue from about a year ago: https://github.com/r0man/cljs-http/issues/103

dpsutton20:10:12

well then... sorry ha

lilactown20:10:24

😆 it's OK. I'm just going to write a wrapper around fetch

dpsutton21:10:33

in clojure i can do (char (+ (int \a) 4)) -> \e is there a good way to get a character at an offset from a?

noisesmith21:10:19

#(char (+ (int %) %2)) ?

dpsutton21:10:29

unfortunately, it seems that (char "a") is "a" and (char (+ (int \a) 4) is "^D" which i think is system bell or something silly

noisesmith21:10:17

user=> (char (+ (int \a) 4))
\e

dpsutton21:10:18

and i can use an offset or 97, just wondering if i could do it in terms of "a" rather than magic-number

dpsutton21:10:34

that's clojure though, right? I'm not seeing the same in clojurescript

noisesmith21:10:50

oh, so sorry

dpsutton21:10:57

no problemo. that's why i'm stumped lol

dpsutton21:10:23

i guess its interop time with charCodeAt

noisesmith21:10:38

yeah, that was going to be my follow up

dpsutton21:10:50

thanks anyways 👍

noisesmith21:10:39

(ins)dev:cljs.user=> (defn char+ [c n] (char (+ (.charCodeAt c 0) n)))
#'cljs.user/char+
(ins)dev:cljs.user=> (char+ "a" 4)
"e"

noisesmith21:10:21

TIL you can leave the index off and it defaults to 0 (probably not recommended for readability though)

bhauman21:10:39

[devcards 0.2.4] is out and is React 16 ready

bhauman21:10:52

thanks to @anmonteiro for helping with this

bhauman22:10:55

@dnolen also just landed support for projects with code splitting in figwheel 0.5.15-SNAPSHOT by leveraging preloads instead of hacky script generation/patching

bhauman22:10:08

now to finally work on something interesting for displaying spec violations in a clean manner