Fork me on GitHub
#clojurescript
<
2017-07-09
>
gfredericks00:07:55

is there some standard integration between lein-cljsbuild and cljs.test?

gfredericks00:07:15

the cljsbuild example file only shows how to run an arbitrary shell command

gfredericks00:07:28

my setup here does not work so well with newer versions of cljs, and I'd like to declare bankruptcy if things have changed sufficiently in the last year https://github.com/gfredericks/exact/blob/3f46ef96eaa26128897d55f83da8274e25b5e0db/project.clj#L15

gfredericks02:07:01

I think I figured it out

jhorwitz05:07:41

Hey everyone, I’m sure this has been asked a billion times, but as an experienced JavaScript react dev, what is the best way to learn cljs? Closure resources or are there others?

meeli10:07:19

jhorwitz: i found clojure koans useful http://clojurekoans.com/

meeli10:07:06

the hoplon get started page is also useful 🙂 https://github.com/hoplon/hoplon/wiki/Get-Started

meeli10:07:24

if you’re already doing redux you should “get” cljs pretty quickly, except that it’s, you know, better 😉

meeli10:07:54

get ready for less boilerplate and actual pure functions

meeli10:07:05

i work with react in my day job and cljs in my own product, so if you have any questions i might be able to help 🙂

mobileink11:07:37

there's a faq for js programmers on the main site.

rauh05:07:10

@jhorwitz The official "Quick start" Is a good start.

bnvinay9207:07:06

How would I integrate clojurescript-based react native into an existing android app?

claudiu10:07:03

Hi, Is there any way or a plugin. So that network requests with edn are displayed nicely as maps in chrome devtools?

lxsameer10:07:48

what do you mean ? you just need to parse them

claudiu10:07:36

agh, edited, meant in google chrome dev-tools 🙂

lxsameer10:07:47

ah, sorry in that case i have no idea 🙂

iku00088818:07:19

Does anyone know how to include the figwheel client js code into a single file build? Seemed like simply setting the :optimizations to :simple does not do the job

juhoteperi18:07:03

@iku000888 Figwheel will disable itself if optimizations is something else than :none because reloading files is not possible with other options

iku00088818:07:28

@juhoteperi Thanks! I was suspecting that is the case. Got curious because I had a constraint where even during dev time the output js had to be a single file.

iku00088818:07:18

I am guessing the best I could go is something like weasel + a watch build in that case?

iku00088818:07:34

(Which is what I have been doing.)

lxsameer19:07:00

what is the best practice to share a configuration value with cljs code ?

darwin19:07:42

@lxsameer I tend to set them in :external-config in compiler options and then use a macro to read them into clojure (to be used by macros) and then optionally emit them into generated cljs code to be consumed there

darwin19:07:07

for libraries I additionally allow overriding them via environmental variables, for people who don’t want or cannot change project settings (verisoned under git)

claudiu19:07:17

@darwin Awessome. that would be a really nice feature for people moving from js to clojurescript 🙂

darwin19:07:48

@lxsameer in case of a library, if you use :external-config make sure to pick unique enough key for your config, ideally namespaced

lxsameer19:07:13

yeah sure, thanks man

lwhorton20:07:10

this is a really random question, but can someone point me to a thing in clojure that implements the ISwap interface? I was looking into how Atom works, which is pretty straightforward… https://github.com/clojure/clojurescript/blob/b7a1b1a75de24734026a34dd0e93ba02e2b076c8/src/main/cljs/cljs/core.cljs#L4365-L4373 but at some point the swap! function invokes -swap! if the given argument is not of type atom. I cannot find anywhere in the codebase where a concrete thing implements ISwap except for this https://github.com/clojure/clojurescript/blob/0aed47861b025eb1b3757a77c7ec425682d01354/src/main/clojure/cljs/core.cljc which I don’t fully understand, but it doesn’t look related (some dynamic defining of a protocol lookup map, maybe?). It does seem to complain properly that no protocol method -swap! defined for cljs.core/{some non-atom type}, but then that begs the question why is it there in the first place?

chouser20:07:13

@lwhorton I have no definitive answer, but it may just be an extension point so people can provide their own types that work with swap!

lwhorton20:07:16

aha, of course. that seems so obvious now

noisesmith20:07:44

@lwhorton clojure design philosophy dictates never defining a method that isn't on an abstract interface https://clojure.org/reference/datatypes#_datatypes_and_protocols_are_opinionated

chouser20:07:50

Meanwhile, I want my *.cache.json files, but with :optimizations :simple, I don't see them. Are they produced and deleted, or just never produced? How can I ask to keep them?

noisesmith20:07:08

if you didn'thave ISwap, you would need to inherit from Atom, and clojure doesn't do that kind of thing

lwhorton20:07:04

Ah I see.. that’s a good reference @noisesmith . So if someone wanted to implement their own behavior on non-atom swap!s, they must have a type / record that implements -swap!, and ISwap is that interface to implement. Otherwise, as you said, you would have to do some sort of inheritance from deftype Atom where you attach/override another method etc., and “clojure don’t play like that”

noisesmith20:07:44

yeah, that's it

noisesmith20:07:16

it's a little different in clojurescript since inheritance is different in js, but the basic principles hold

lwhorton20:07:43

‘tis amazing how many of these things i’ve read and reread, but never really understood

chouser20:07:28

...and now that I've actually articulated my question, the answer is easy to find: :cache-analysis true

skammer22:07:19

Hey, I’m trying to compile a clojurescript node app using this config:

(cljs.build.api/build
 "src"
 {:optimizations :none
  :main 'cri.core
  :npm-deps {:chrome-remote-interface "0.24.1"}
  :closure-warnings {:non-standard-jsdoc :off
                     :common-js-module-load :off
                     :violated-module-dep :off}
  :language-in "ecmascript-next"
  :compiler-stats true
  :parallel-build true
  :target :nodejs
  :verbose    true
  :output-dir "target"
  :output-to "target/main.js"})

skammer22:07:52

But keep getting this error:

clojure.lang.ExceptionInfo: No such namespace: chrome-remote-interface, could not locate chrome_remote_interface.cljs, chrome_remote_interface.cljc, or Closure namespace "chrome-remote-interface" in file src/link_archiver/core.cljs

anmonteiro22:07:29

well that’s probably because Closure failed to consume your chrome-remote-interface dep

anmonteiro22:07:47

and you might be swallowing the errors it throws 😞

skammer22:07:16

clojurescript does process it though

anmonteiro22:07:26

anyway, if you’re compiling for Node.js, why not just (js/require "chrome-remote-interface")?

skammer22:07:05

sure, that’s one way 😄

skammer22:07:58

just wondering why it does work with left-pad and fails here

skammer23:07:01

it does get processed with compiler though. I can see it in target/node_modules/chrome-remote-interface and index.js has some goog.provide shenanigans

anmonteiro23:07:56

trying to repro

skammer23:07:53

btw [org.clojure/clojurescript "1.9.671"]

anmonteiro23:07:07

I can repro, but not gonna spend any time figuring it out

anmonteiro23:07:24

^ we’re dropping support for :npm-deps with :target :nodejs in the next release of ClojureScript

anmonteiro23:07:11

it’s only meant to be used for the browser

anmonteiro23:07:17

Node.js has its own facilities for consuming modules

skammer23:07:12

sure, ok makes sense now

anmonteiro23:07:39

@skammer btw I figured out the problem anyway

anmonteiro23:07:58

the chrome-remote-interface module doesn’t have a "main" entry in its package.json

anmonteiro23:07:20

which I guess might have uncovered a problem in ClojureScript

anmonteiro23:07:28

but I need to look closer

anmonteiro23:07:43

@skammer I also couldn’t get it to repro without adding entries for

{:utf-8-validate "3.0.3"
 :bufferutil "3.0.2"}

anmonteiro23:07:46

not sure if expected

skammer23:07:35

yep, I had to add them as well. I guess it kept compiling while after I removed those from :npm-deps because I already had them in node_modules or something

skammer23:07:34

would be nice to default :language-in to at least :es-6, as some npm modules are using it already

jhorwitz23:07:14

Is it necessary to learn clojure prior to clojurescript?

noisesmith23:07:59

not neccessary but maybe easier - clojurescript has more odd details you need to remember

skammer23:07:14

differences are subtle enough to not matter, imo

skammer23:07:40

unless you want to interop with js, evidently 😄

noisesmith23:07:46

the tooling for cljs is a bit weirder though, and the clojure tooling is a prerequisite in most cases

noisesmith23:07:30

that is, most people won't get a good cljs env set up without getting a good clj env first

noisesmith23:07:12

(self hosting like lumo or planck changes this of course, but I don't think it's as common as using clojurescript.jar via leiningen or boot)

anmonteiro23:07:51

@skammer thanks for bringing this up though, there’s definitely a ClojureScript bug here 🙂

souenzzo23:07:51

clj->js bug? (clj->js {nil :foo}) => #js {:nil "foo"} . On js, like on clojure, {null: "foo"} is possible #js {nil "foo"} throws