Fork me on GitHub
#clojurescript
<
2017-01-28
>
isak00:01:42

got it fixed. Was just an invalid use of sablano/html macro that used to be ok.

johanatan01:01:43

is the following a known bug?

johanatan01:01:50

=> (cljs.reader/read-string "{:21 nil}")
#object[TypeError TypeError: Cannot read property '0' of null]
   cljs$reader$read_keyword (jar:file:/Users/jonathan/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:367:21)
   cljs.reader/read-delimited-list (jar:file:/Users/jonathan/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:233:23)
   cljs$reader$read_map (jar:file:/Users/jonathan/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:284:12)
   cljs.reader/read (jar:file:/Users/jonathan/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:464:22)
   cljs$reader$read_string (jar:file:/Users/jonathan/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/reader.cljs:477:6)
nil

dnolen01:01:20

@johanatan it’s not a bug, that’s not a valid keyword

johanatan01:01:20

then these two are bugs:

=> {(keyword "12") nil}
{:12 nil}

=> {:12 nil}
{:12 nil}

johanatan01:01:37

and this one:

=> (pr-str {:12 nil})
"{:12 nil}"

dnolen01:01:57

or just undefined behavior

dnolen01:01:30

refer to this for things to avoid

johanatan02:01:19

@dnolen: 👍:skin-tone-2:thx!

rcanepa02:01:43

Hi everyone. I'm stuck at the download ClojureScript step from the quick-start guide. For some reason, executing curl -L returns an XML response, which contains this error message: <Code>NoSuchKey</Code><Message>The specified key does not exist.</Message>. Is anyone else having the same problem? Am I doing something wrong?

anmonteiro02:01:35

@dnolen ^ you might have forgotten to attach the cljs.jar to the release

dnolen02:01:12

Will take a look later

dnolen02:01:30

Not at computer

ustunozgur03:01:41

Thank you to all those involved. This looks like a very significant release.

jumar04:01:43

@rcanepa it seems that there is no cljs.jar for the release you’re trying to download on GitHub - only Source code: https://github.com/clojure/clojurescript/releases/tag/r1.9.456

jumar04:01:47

It may be that @dnolen still needs to finish the release - I don’t know how this process look like

rackdon07:01:45

There is any library like clj-webdriver? This is unmaintained 😔

martinklepsch07:01:01

@rackdon not quite the same but this might be interesting: https://github.com/jackrusher/sparkledriver

tianshu07:01:03

is it possible to use #js in the generated code in macro?

(defmacro foo [m]
  `(print #js ~m))
like this? I don't want to transform the inner structures of m.

grounded_sage11:01:48

Is it possible to share the state of an atom generated in clojure in clojurescript during a build. I've got an issue where CSS class names are being being generated with a macro in CLJ for serverside rendered HTML. But when the cljs is generated for the client side version it appears to be starting the atom again and creating different class names which messes up the styles client side.

rauh11:01:07

@grounded_sage You could persist the data to disk and also load it when your macro file gets loaded

rauh11:01:40

could help. Simple, no deps

grounded_sage11:01:10

@rauh: I suppose I could put it into the fileset as a string and then grab it back out again. It's just strange. Serverside using the macros you created works fine. However somehow client side it puts a different class name onto the HTML elements which is attached to different styles. I'm just super confused how it is messing up the styles so trying to dive in and resolve it.

rauh11:01:16

Server and client are two different JVMs so they don't know of each other

grounded_sage11:01:27

I use the 'css' macro in both CLJ and CLJS

rauh11:01:31

the generated classnames depend on the order how they're called

rauh11:01:10

so the css fn is not a "pure function". It'll return completely different classnames everytime

grounded_sage12:01:18

The thing that confuses me the most is I have say '{:margin-right "2em"}' which renders as class name [S1]. But when CLJS builds it somehow puts the class name [SM]. Which is attached to '{:color "green"}'. So I don't know if it is the atom getting messed up or it's not getting the style class name from the atom correctly.

rauh12:01:32

The problem is the classnames are generated and are completely different everytime the macro namespace gets evaluated.

rauh12:01:19

If you want to have the same classnames client+server side then you'll have to persist the atom (or you could make it more complicated)

thheller12:01:52

@grounded_sage @rauh do not go down this path, there be dragons.

thheller12:01:14

in general you do not want the compiler to generate state that the client is going to use

thheller12:01:29

as the compiler may not actually compile a file but instead use a cached version

thheller12:01:42

but that cached version will not account for your state, so it will be missing

rauh12:01:28

Yeah the entire stateful macro's thing can be a little difficult

rauh12:01:35

That I've learnt 🙂

thheller12:01:11

you can however use information that is going to be the same on each invocation

rauh12:01:13

Still works well with one clean compilation run though.

rauh12:01:55

(FYI, we're talking about the proof of concept I did a while ago: )

thheller12:01:49

yes you can abuse this ... doesn't make it a good idea

grounded_sage12:01:48

@thheller: can you expand on using the same information? Like an example maybe?

thheller12:01:52

so, I wrote a library that is not open-source yet ... but related to this css so I'm going to use it as an example

thheller12:01:59

(defstyled section-header :div
  [env]
  {:font-size 22
   :margin [0 0 10 0]
   :color (-> env :colors :primary)})

thheller12:01:17

this is in a sense like styled-components from react

thheller12:01:34

you use this via [section-header {} ... ]

grounded_sage12:01:01

@rauh: Do you think it's worth continuing to develop your proof of concept or with the latest news of working better with ES6 wrapping styletron itself?

thheller12:01:02

which generates a div with the generated className

thheller12:01:21

the generated classname is generated by the macro

thheller12:01:42

basically my-ns--section-header

thheller12:01:15

so it uses the current ns and the name of the def (ie. section-header)

thheller12:01:24

to derive the classname

thheller12:01:32

that information is static and never changes

rauh12:01:46

@grounded_sage Well, it's very rough around the edges and def not user friendly. It would need some work to make it easier and more robust. I do use it successfully but I know my way around so I can fix things quickly if stuff goes wrong. YMMV

thheller12:01:37

hope that makes some sense

grounded_sage12:01:15

@thheller: so you mean the process of generating the information always produces the same result. Instead of generating random class names which can change based on threading etc

rauh12:01:20

If you're new in cljs land my styler might be a wast of time since it's hard to debug (macros are already advanced, even more so in cljs)

rauh12:01:54

@grounded_sage Yes, a stateful macro is usually a very very bad idea 🙂

rauh12:01:40

A durable "registry" file keeping all used classnames somewhere would fix that part.

thheller12:01:45

(defmacro defstyled [el-name el-type args & body]
  {:pre [(simple-symbol? el-name)
         (keyword? el-type)
         (vector? args)]}

  `(let [css-sel# (shadow.react.css/gen-css-sel ~(str *ns*) ~(name el-name))]
     (def ~el-name
       (shadow.react.css/->StyledElement
         ~(name el-type)
         css-sel#
         (fn ~args
           ;; for live-reloading, forget rules first as style-fn is only ever called once when invoked correctly
           (shadow.react.css/forget-rule! css-sel#)
           ~@body)))))

thheller12:01:50

that is a bit out of context

thheller12:01:26

but the [css-sel# (shadow.react.css/gen-css-sel ~(str *ns*) ~(name el-name))] is how the classname is generated

thheller12:01:52

and this information is static

thheller12:01:14

so (gen-css-sel "my.ns" "section-header") is called

thheller12:01:47

this is currently cljs only but you can easily do this in clj

thheller12:01:00

if you don't want to actually leak the namespace information you could easily just hash the thing or something similar

thheller12:01:23

as long as only the ns and name are used you are safe

grounded_sage12:01:12

@rauh: I'm prepared to dive in and spend some time playing around with this stuff. Only way to learn! I'll give the whole dumping the atom in the file a go and see if it fixes the problem I have

sihingkk14:01:44

Hey guys I wonder if anyone has experience using electron-packager together with boot-cljs I’m experimenting with https://github.com/martinklepsch/electron-and-clojurescript When building app this way:

boot build-prod target
electron-packager target/ MyApp --platform=darwin --arch=x64 --version=0.31.2
open MyApp-darwin-x64/MyApp.app
I’m getting on app starting (after building it with electron-packager:
Error: Cannot find module '/main.out/goog/bootstrap/nodejs.js'
and it’s because there is main.js generated which use
require(path.join(path.resolve("."),"app/main.out","goog","bootstrap","nodejs.js"));
to require files. the problem is path.resolve(”.”) evaluates to / for build electron process (https://github.com/clojure/clojurescript/blob/cdaeff298e0f1d410aa5a7b6860232270d287084/src/main/clojure/cljs/closure.clj#L1405). do you have perhaps any ideas how to solve this issue?

jsselman18:01:59

How do people handle run-time configuration of their clojurescript logic? For example, I built an uberjar that contains a ring server hosting both compiled cljs and a websocket server, however I need to somehow pass the websocket url to the application at runtime. Would using something like enlive to dynamically embed the url at the top of the page (before including the compiled cljs script) work? Is there a better approach?

darwin18:01:27

depends, passing arguments as url parameters, including script tag with configuration, or as you suggested embedding configuration into page by server

darwin18:01:24

when the configuration is known at compile time I use macros to alter stuff which gets emitted, e.g. eliding debug logging

nikki21:01:02

seems there has been buzz about new things that are / have been recently added to cljs?

nikki21:01:05

where can i read about these features?

nikki21:01:13

sry still new to the community and not sure what the news place is