Fork me on GitHub
#clojurescript
<
2016-06-22
>
ag00:06:15

guys, I just don’t get it… It cannot be that complicated. I am trying to find relatively painless way to consume third-party JS libs and modules. After trying out couple of things (e.g.. webpack), I’m back to at where I started. I thought using https://github.com/cljsjs/packages is the easiest and kinda right way, but it has a major problem of version incompatibility. Whoever wraps a lib into cljsjs package, wouldn’t be of course updating it every time original module gets updated. Can someone show me a canonical way of consuming JS lib straight from NPM?

danielcompton00:06:10

@ag, maintainers generally do update cljsjs with new versions pretty frequently

danielcompton00:06:21

and it’s not too tricky to do it yourself and submit a PR IIRC

sbmitchell00:06:53

I've updated several packages but I dont think it is true they are updated "frequently" only based on need

sbmitchell00:06:10

it is relatively straight forward to make packages though

sbmitchell00:06:26

I also think you need to do it that way to make stuff work with adv comp

sbmitchell00:06:36

not necessarily thru cljsjs packages but using foreign-libs

sbmitchell00:06:25

I don't see why couldnt just reference the JS inside of your html file if you dont care about adv builds

ag00:06:57

@danielcompton: simple example… let’s pick up a random package…. say react-datepicker… latest packaged version is 0.15.2. Latest package on npm 0.27.0. You say “just update it yourself”, this package has only 3 dependencies.

ag00:06:59

but what if it had more?

sbmitchell00:06:12

the latest packaged version where?

ag00:06:38

in cljsjs/packages

sbmitchell00:06:04

ok and what makes it hard to update it?

sbmitchell00:06:26

I guess my point is that these components are not made in CLJS land its never going to be "easy" per se because they are not targeting google closure compiler

sbmitchell00:06:11

its not as nice as npm install blah but its what we have lol

ag01:06:59

I’m just refusing to believe that nobody solved this problem. CLJSJS although nice, yet it’s not a solution. it’s an attempt to obscure the original problem.

sbmitchell01:06:44

would like to know myself 🙂

sbmitchell01:06:16

Are you stating the original problem as, how do I get the latest version of a javascript lib?

ag01:06:57

Being new to Clojure and Clojurescript I'm being perplexed very often. Whenever someone says something similar to "lein startup time is not a problem" I feel really surprised. I guess I'm too green to develop stockholm syndrome.

ag01:06:47

@sbmitchell: the original problem is that I can’t find a "canonical way of consuming JS lib straight of npm"

sbmitchell01:06:38

Looks like there is a lein plugin that may help? https://github.com/RyanMcG/lein-npm

ag01:06:04

@sbmitchell: lein npm just grabs stuff out of npm. you still have to solve problem of feeding js modules into closure compiler pipeline

ag02:06:21

@danielcompton: yeah, I saw this page, Maria Geller is amazing. I wish I could afford to have patience to wait until CommonJS/ES6 module support is implemented. I need a working solution or at least a workaround now ;(

mfikes02:06:37

Actually @ag, :commonjs and :es6 are implemented. The fundamental problem is that it doesn’t really work for your goal of code packaged for use with Node.js. But, if you are interested, here is the link to the :foreign-libs / :module-type compiler option configuration: https://github.com/clojure/clojurescript/wiki/Compiler-Options#foreign-libs

hlolli07:06:30

Does someone have an example of sending data to google analytics in react based cljs spa. This may be more of a question to secretary/routing. I see some old code when I google this, not sure if its still valid.

jimmy07:06:31

@hlolli: check frontend from circleci , they do use ga https://github.com/circleci/frontend

dominicm07:06:03

Is there any information on places you can lose scope in Clojurescript, and perhaps with some information on avoiding these pitfalls.

hlolli07:06:28

@nxqd: This is one deep rabbit hole 🙂

hlolli08:06:08

ahh, an easy solution 🙂 nice.

hlolli08:06:56

seems like this does not include hashed uri changes, which I base my router on. Maybe a bad idea.

martinklepsch09:06:02

@ag as others pointed out there are two ways to use JS code, one is to do the module transformation (not there yet) the other is externs. Because externs might have to be updated for library updates updating a lib isn't a straightforward (automatable) process. This can lead to "lagging behind". The CLJSJS tooling is intended to make it as easy as possible for someone to update packages and submit new ones to take most of the chore out of it. Still the externs bit is an unsolved problem that needs to be taken care of manually.

martinklepsch09:06:31

(this is all assuming you want :advanced optimizations)

x1n4u09:06:14

hi, i have following problem: How do I access the value of a javascipt object with a - in its name, normally i do (.-name object) but this doesn't seem to work for (.-name-name object)

ajchemist09:06:31

@x1n4u: use (aget object “name-name”) instead.

plexus09:06:09

note that aget is really meant to be used with arrays. You can use gobj/get instead

plexus10:06:06

I can't get the cljs.repl.browser to connect from Firefox on Linux. Works fine on Chrome. I'm using the exact code from the Quick Start... is this a known issue?

plexus10:06:54

it says > If the REPL doesn't connect immediately try refreshing the browser a few times (Chrome & Firefox tend to be more stable than Safari). but refreshing a dozen times still doesn't make a difference

x1n4u10:06:39

ajchemist: tahnks

plexus10:06:23

@peterschwarz: haven't tried it but cljs.analyzer/with-warning-handlers might be what you're looking for.

dnolen12:06:37

@dominicm: what do you mean “lose scope”?

dominicm12:06:38

@dnolen: I was a little confused about what I was seeing this time. But I spent a lot of time chasing down bugs with dynamic vars disappearing only in advanced builds, because of how they're set in advanced mode. I also have something in the back of my head about losing scope (maybe let bindings?) when you register an event.

dnolen12:06:09

@jiyinyiyong: the bottom graph looks fine, typical gc cycle - the one above might have a leak - you can force a full GC. If you believe there is a leak use the heap profiler.

dnolen12:06:41

@dominicm: there are no special scoping rules

dnolen12:06:00

dynamic vars disappearing nor issues with let are anything I’ve encountered or heard specific reports about

dnolen12:06:30

there’s nothing special about dynamic vars and advanced compilation

dnolen12:06:56

there might be an issue of course - but would need much more specific information (minimal case)

dnolen12:06:13

@ag I’d warned you a while back that what you’re trying to do is not that common 🙂

dnolen12:06:31

most people are doing web stuff. The typical thing from what I can gather is for people who are really set on using NPM for deps, use Webpack or whatever to build a single foreign lib and include that into the ClojureScript build.

dominicm12:06:13

@dnolen: It was to do with laziness, so it's expected behaviour, but it's working on ":none" builds made it confusing. What I read in the resulting js (so grain of salt) is that in advanced, dynamic vars use a global var, but in :none, they were available later anyway (unique var names in :none I think?) Essentially, I think I was wondering if there's a list of gotchas for this sort of thing. Admittedly though my motivation was fueled by an issue this morning which I thought to be related, but have since realised isn't. "wat" moments.

dnolen12:06:56

@dominicm: that doesn’t have anything to do with ClojureScript, more generally a Clojure thing

dnolen12:06:23

but yes you shouldn't expect lazy computations to see bindings which are long gone

dnolen12:06:53

anything around optimization settings is beside the point

dnolen13:06:03

spec fixes and :preloads compiler option for simpler dev tooling config

wilkerlucio14:06:17

@dnolen: nice, thanks for the release, could you please add the :preloads with an usage example at https://github.com/clojure/clojurescript/wiki/Compiler-Options?

dnolen15:06:20

free cool idea from ClojureScript IRC - bootstrapped ClojureScript slideshow/presentation thing-y 🙂

shaunlebron15:06:41

i’ve been working on showing cljs release posts in a central place: http://cljsinfo.github.io/news/

shaunlebron15:06:30

also shows what’s been added to the API after the text that david posts

shaunlebron15:06:30

content feedback is welcome, design should be ignored for now

pesterhazy16:06:17

cljsinfo is awesomesauce

pesterhazy16:06:01

could we add it to the channel topic?

dnolen17:06:24

@bhauman: the unrecognized key behavior of Figwheel is super annoying

dnolen17:06:54

while I understand it’s useful for beginners tooling really needs to get out of the way of people who know what they are doing

dnolen17:06:39

@bhauman: is there a way to control this behavior?

bhauman17:06:10

@dnolen: there is churn here now, I'm looking at it, :validate-config false is a thing

dnolen17:06:49

@bhauman: is that passed to :figwheel-options or elsewhere?

bhauman17:06:56

in :figwheel-options

bhauman17:06:51

@dnolen: do you have a repo of a workup of figwheel over socket repl?

dnolen17:06:15

I don’t but let me make a gist

bhauman17:06:32

take your time it's not urgent

bhauman17:06:41

but I'm interested

bhauman17:06:38

Also, I'm hopefully going to release a figwheel today that takes :preloads

bhauman17:06:57

and I'm working hard on using spec to do the validation

bhauman17:06:03

awesome thanks 🙂

dnolen17:06:07

CLIENT_IP/PORT will likely just be SERVER_IP/PORT

dnolen17:06:18

just depends on your setup

bhauman17:06:18

yeah gotcha

bhauman18:06:28

its such a short script 🙂

bhauman18:06:26

@dnolen: looking at that gist, I thought I'd let you know that :websocket-url templates are a thing now :websocket-url "ws://[[client-hostname]]:[[server-port]]/figwheel-ws"

dnolen18:06:22

yeah I actual having something fancier inside of a component thing

dnolen18:06:29

but the essence of the thing is really, really simple

wilkerlucio18:06:13

trying to use the :preloads, but I'm getting:

WARNING: preload namespace quote does not exist
WARNING: preload namespace [:support.dev] does not exist

wilkerlucio18:06:17

using :preloads '[:support.dev]

bostonaholic18:06:34

@wilkerlucio: try :preloads '[support.dev] instead

wilkerlucio18:06:16

@bostonaholic: thanks, I actually tried all variations I can think of on this: '[support.dev] ['support.dev] [:support.dev]

bostonaholic18:06:18

> :preloads must be a sequence of symbols

wilkerlucio18:06:38

but none of then did the trick, I posted that one here because the example at the wiki is like that, but maybe it's wrong there

bostonaholic18:06:13

the one on the wiki is not like the one you posted

bostonaholic18:06:29

(unless we’re looking at two different wikis)

wilkerlucio18:06:58

ha, I refreshed the wiki page and it changed, here, hehe, probably was fixing during the meantime

wilkerlucio18:06:40

but still getting

WARNING: preload namespace quote does not exist
WARNING: preload namespace [support.dev] does not exist

dnolen18:06:07

@wilkerlucio: symbols not keywords, there was a typo in the wiki

dnolen18:06:26

the wiki also states that the namespace has to A) exist B) be discoverable on the classpath

bostonaholic18:06:26

is that namespace on your classpath?

wilkerlucio18:06:10

its a regular namespace, side by side with my other sources, when you say classpath you mean other more than the lein source paths?

dnolen18:06:45

lein source paths just adds entries to the classpath

dnolen18:06:22

@wilkerlucio: the problem is that lein implicitly quotes everything

dnolen18:06:30

so you’re double quoting

dnolen18:06:34

that warning is the hint

dnolen18:06:05

just drop the quote

wilkerlucio18:06:15

ah, gotcha, yeah, it works now, after removing my extra quoting

dnolen18:06:27

I tweaked the wiki

dnolen18:06:38

gotta say that’s a real Lein misfeature

dnolen18:06:54

@darwin: got cljs-devtools working with preload, much nicer than the manual steps you have 🙂

darwin19:06:11

I’m going to update[1], will be much easier/shorter with preloads [1] https://github.com/binaryage/cljs-devtools/blob/master/docs/install.md#dev-builds we just want to settle with @bhauman on a good name for :tooling-config, we want to change it, because it will be useful for libraries and other things to pass through extra parameters without figwheel complaining

darwin19:06:33

so far best proposals: :external-config meaning “external to compiler” :passthrough-config meaning “will be passed through to macros"

darwin19:06:20

figwheel will not validate subtree of this key if found

darwin19:06:42

we are open to suggestions, this thing will probably stick with us, because anyone who will want to pass some extra options to their macros will probably want to use this key, because otherwise figwheel would complain when validating their configs

richiardiandrea19:06:13

:tooling-config is clear enough imho

darwin19:06:34

@richiardiandrea: but what about for example chromex wanting to pass config? chromex is a library, not a “tool"

darwin19:06:48

we need a more general name IMO

darwin19:06:25

I used to use environ to propagate configs to my macros, but that is fragile[1] with lein. I’m going to update all my libraries to use this newly discovered technique of passing config to my macro code. [1] https://github.com/weavejester/environ/pull/53

gowder21:06:48

Is js->clj known to be broken? I'm trying it out in a chrome extension that takes a message in json format, and it looks like it converts a javascript object to a map when passed {:keywordize-keys true}, but doesn't actually keywordize the keys; by contrast, when it's not passed an option map at all, it just silently fails.

darwin21:06:43

@gowder: call it like this (js->clj jsobj :keywordize-keys true)

darwin21:06:51

got bitten by this multiple times

gowder21:06:08

rather than as a map? interesting---thanks @darwin

darwin21:06:26

sorry, edited a typo ^

gowder21:06:36

testing now...

darwin21:06:50

btw. check out my library chromex[1] if you are not aware already (a shameless plug) [1] https://github.com/binaryage/chromex

gowder21:06:53

I'll definitely check it out! thanks again

gowder21:06:30

I'm actually doing a really janky build process. trying to build a half-js half cljs chrome extension as the front-end to an internal system for some research assistants, so right now I've got like three different git repos with different pieces of code in there, and am just copying them over, doing a lot of direct access to chrome api from cljs... maybe the discipline of a wrapper library will help 🙂

darwin21:06:30

look here[1][2] for an example of real-word extension using chromex (just to get feel of it): [1] https://github.com/binaryage/dirac/tree/master/src/background/dirac [2] https://github.com/binaryage/dirac/tree/master/test/marion

darwin21:06:49

in short "core.async saved the day"

gowder21:06:04

incidentally, I wonder why js->clj takes the options inline rather than as a map. isn't the usual idiom to pass keyword options as a map?

gowder21:06:12

core.async always saves the day 🙂

darwin21:06:31

I think the idiom is to pass options as a map, but js->clj may be older than this idiom 😉

gowder21:06:56

Hah there is that!

dnolen21:06:11

@gowder: yes it’s an old feature

darwin21:06:29

cljs.spec for the rescue!

gowder21:06:46

Yes! spec all the things!

bhauman23:06:57

just deployed lein-figwheel 0.5.4-4 with support for the new :preloads key and some other fixes