Fork me on GitHub
#clojurescript
<
2017-08-09
>
josh_horwitz02:08:26

Hey everyone, as someone newer to ClojureScript, what is the recommended framework to get started with after learning the language basics?

dviramontes04:08:17

Hi 👋:skin-tone-5: Josh! I would recommend checking out http://reagent-project.github.io/ the learning curve is not as steep as some of the other CLJS front-end frameworks and its pretty expressive and functional (it uses react under the hood too)

dviramontes04:08:30

there is also a pretty good list on https://www.clojure-toolbox.com/

alex-dixon15:08:53

Hello! I would recommend both as well and maybe re-frame

tony.kay07:08:57

Has anyone had any luck getting code splitting modules to work under any optimization level with 1.9.854 and lein cljsbuild? I keep getting an assertion error when I try to load a module: ” Assert failed: Module does not exist”, where the module name in that message is nil (the message is supposed to say “Assert failed: Module :x does not exist”, where :x is the thing you tried to load; however, I’m calling load with a keyword and a callback. When I trace it in the browser the module info has the module, but sure enough the module name is turning nil somewhere along the way. The js is a little hard to read, so I’m still not sure where it is going wrong, but seems like a bug to me.

symfrog07:08:07

@tony.kay I have been working with modules recently, I have not come across that specific issue. If you could make a minimal case available that reproduces the issue I could take a look?

joelgluth12:08:21

Hey channel... I am having trouble with some old code in the Clutch couchdb client that uses cljs/closure. It's based on an ancient version of the ClojureScript compiler, and breaks when I try and use it with something modern (in this case, 1.9.854). In particular, if I try and do something like this, which used to be legal:

(closure/build '[(ns foo) (defn str-dentity [y] (str y))] {:optimizations :simple :main 'foo/str-dentity})
I get the error
java.lang.AssertionError: Assert failed: No file for namespace foo/str-dentity exists
I get the feeling (though I am guessing) that the single-file logic (triggered by :optimizations and :main) expects me not to be trying to compile a quoted code literal. Is that even supported nowadays?

joelgluth12:08:50

Thanks - that's what led me here. I guess I'm wondering if the feature I'm trying to use is deliberately no longer supported, accidentally borked by the single-file logic, or supported in some other fashion in these modern times.

sundarj12:08:18

the feature being a quoted literal?

joelgluth12:08:32

Quoted literals still work - my specific problem appears to be exporting one as a :main.

sundarj12:08:23

isn't the error because it can't find a corresponding file for the 'foo' namespace?

joelgluth12:08:54

Right. And the namespace is created in the input list. Which is to say, it doesn't have a file.

sundarj12:08:15

so the error would be expected, no?

sundarj12:08:00

unless im missing something

sundarj12:08:32

i am not aware of how it used to work

joelgluth12:08:47

😉 The point being that this used to work - when Clutch was written, you could do exactly this trick. Now it appears you cannot, and I'm trying to figure out a) whether that is deliberate, and maybe b) if there's a different way to achieve the same end.

sundarj12:08:43

right, sorry i couldn't be of assistance.

sundarj13:08:18

i can't see anything in the changelog about it

joelgluth13:08:56

The wider context is that Clutch uses the feature to generate JS views for execution by the CouchDB server - and they have to be something you can send encoded as part of a POST request, expressed as a single JS callable.

joelgluth13:08:32

No worries @U61HA86AG , thanks for looking though. The quest continues...

assassinduke12:08:30

hey guys is there a way to make a function repeat at a set number of seconds

manutter5113:08:45

Maybe just define a setTimeout function that calls your function once, and then re-queues itself with another setTimeout?

assassinduke12:08:43

like each second

cycle33712:08:28

try (js/setInterval (func-name) 100)

assassinduke12:08:26

i know about that but i need a live feed of the state in my repetition

assassinduke12:08:53

and using set inverval it gets locked on the first state that is gets

dnolen13:08:17

@joelgluth I read through that thread - it is supported but you are trying to combine it with :main

dnolen13:08:48

far as I can tell :main didn’t exist back then and what you want to do was never supported

dnolen13:08:10

also your :main doesn’t even match existing usage

dnolen13:08:35

:main must be a namespace that corresponds to a file on the classpath

dnolen13:08:50

I would just remove that, and your build should work

dnolen13:08:57

(it seems you think :main corresponds to Clojure’s idea of :main - this is not true and never has been)

joelgluth13:08:01

Cheers @dnolen ! Some more context is that this is not my code; I'm wanting to use the Clutch couch client and trying to understand why it won't work with modern CLJS. It seems like Clutch's technique is a bit of a hack that maybe worked for a small window of time.

dnolen13:08:19

we own compiler options

dnolen13:08:36

if we take a name, other tooling must deal with it

joelgluth13:08:59

Indeed 🙂

joelgluth13:08:14

Reading their code, I think they were using :main as a way to avoid the Closure compiler optimizing away a containing callable, which CouchDB wants.

joelgluth13:08:09

This is not vital to my life, just interesting. I'll keep digging around and see if I can make it do that a different way.

joelgluth14:08:33

(It turns out that that part of Clutch was written for cljs 0.0-1450, and works up until cljs 1.7.58 inclusive.)

shzhng14:08:18

hey folks, reasking again from last night 😄 - what is the proper way to include scoped packages with :npm-deps?

shzhng14:08:58

if i provide it as a symbol, such as :@namespace/pkg it ends up just looking for pkg on npm

sundarj14:08:17

you use a string - {:npm-deps {"@scope/pkg" "1.0.0"}}

shzhng15:08:51

sweet thank you

sundarj15:08:20

no problemo

shzhng15:08:35

curious - how do i then reference it in my ns requires?

sundarj15:08:43

also a string

hlolli14:08:39

someone encountered this unwanted space when generating extern with the genereate-extern tool

Extern for material-ui
 Generated by 
var material - ui = {
  "AppBar": { .... etc...
Or would it be an indicator that this extern is not the right symbol.

mfikes14:08:45

@hlolli The var name is arbitrary, so the tool should probably munge (to perhaps material_ui). Otherwise it is being treated as a JavaScript minus operation.

hlolli14:08:31

yes, realized that minus sign is not leagal symbol in js.

define("material-ui",["react","react-dom","react-transition-group/TransitionGroup"],t):"object"==typeof exports?exports["material-ui"]
this probably causes the tool to find that symbol. This is from the pre-release material-ui 1.0.

hlolli14:08:05

not going to spend more time on this, I won't compile advanced for now 🙂

shzhng15:08:03

is there a way to specify a closure-compiler version to use with clojurescript? specifically trying to use the develop build which includes this fix https://github.com/google/closure-compiler/pull/2596

joelgluth16:08:36

Further to my question about closure/build above, I've figured out what is going on (or was), but the explanation is kind of wordy and I have some other detailed questions about compilation as a result. I don't want to clog up the channel with my personal rabbit-hole if it's not appropriate... is there somewhere better I should take this?

tony.kay16:08:58

@symfrog Thanks. It’s nice to know I’m not hitting a build tool issue 🙂

joelgluth16:08:41

Not entirely-unrelated question: If I want to provide a quoted literal to closure/build (say, '[(fn [x] (str x))]) and get back something (doesn't matter how big) whose value when evaluated was that function, without loading external JS files, is that possible? I'm open to adding boilerplate either to the form or to the compiled JS if it will help.

xanderseren18:08:29

I'm having trouble figuring out how to remove a value from a nested set in an atom. I am able to conj the value into the set but I don't know how to remove that value. Example below is my failed attempt to use dissoc

(let [post (atom {:collaborators #{}})]
  (if (= true some-value)
    (swap! post update-in [:collaborators] conj "thing")
    (swap! post update-in [:collaborators] dissoc "thing")))
What is the correct way to do this?

symfrog18:08:23

@xanderseren You should be able to use disj (https://clojuredocs.org/clojure.core/disj) instead of dissoc

xanderseren18:08:48

@symfrog perfect! that worked 🙂

mfikes18:08:23

@shzhng I would imagine you could get away with specifying your own version of this dep: https://github.com/clojure/clojurescript/blob/master/project.clj#L17 especially if you are using a compatible version of ClojureScript

mfikes18:08:48

@joelgluth Are you saying that you’d like standalone JavaScript? In other words (fn [x] (str x)) involves a call to cljs.core/str, while (fn [x] (inc x)) ends up emitting JavaScript that looks like (function(x) { return x + 1;})

lvh23:08:06

I’ve added "@google-cloud/logging" "1.0.5" to npm-deps, but require-ing ["@google-cloud/logging" :as Logging] does not work with the following error:

Caused by: clojure.lang.ExceptionInfo: No such namespace: @google-cloud/logging, could not locate _CIRCA_google_cloud_SLASH_logging.cljs, _CIRCA_google_cloud_SLASH_logging.cljc, or JavaScript source providing "@google-cloud/logging" in file /Users/lvh/Latacora/Code/cspshovel/src/cspshovel/gcp.cljs {:tag :cljs/analysis-error}
doing require("@google-cloud/logging"); from a node repl in that dir works fine. Is it because of the at sign or something?

anmonteiro23:08:31

@lvh are you consuming this from node or browser?

anmonteiro23:08:57

there might be 2 bugs here

anmonteiro23:08:13

give me some more time