Fork me on GitHub
#clojurescript
<
2016-09-23
>
bthesorceror06:09:07

has anyone had issue in linux with cljsbuild foreign libs? I have a remote url for file and on my mac it works but in ubuntu its trying to look in the local file system

tiensonqin06:09:35

Anyone knows how to represent ES7 static properties in cljs?

tiensonqin06:09:05

Figure it out, it’s my problem.

dm308:09:18

I think there's a bug in cljs analyzer when analyzing contents of loop where recur forms are macroexpanded into, e.g.:

(defmacro if-zero [v a-val a-clause b-clause]
  `(if (= ~v 0)
     (let [~a-val (str ~v)]
       ~a-clause)
     ~b-clause))

(loop [x 1]
  (if-zero x
    val (println "got" val)
    (recur (dec x))))
fails with Can't recur here at line 10. Same snippet in Clojure works fine.

dimovich09:09:41

how can I add a timeout to shoreleave remote call?

andre09:09:09

hi guys, if i'm using only :require-macros , it doesn't include my cljs files , so i have my macro in clj file, it calls my function in the same namespace in cljs file, and if i :require this macro, it WARNING: Use of undeclare var which in my cljs file

timgilbert12:09:26

@andre: I generally use a .cljc file if I’m defining a macro in ClojureScript; you can put the functions and macros in a single file that way. It might be easier to see what’s wrong in your case if you post a little code snippet though

andre12:09:32

using

(:require [re-frisk.core :refer-macros [def-view]])
instead
(:require-macros  [re-frisk.core :refer [def-view]]))
works fine

timgilbert12:09:28

I think if you’re on a recent version of ClojureScript, you can actually just (:require [re-frisk.core :refer [def-view]]) and ClojureScript will figure out whether it’s a macro or not, that feature landed I think last month or so

timgilbert12:09:30

On a completely unrelated note: does anyone know whether a ClojureScript library currently exists that will parse the namespaced-key EDN format that Clojure 1.9 now produces? Eg, #:user{:name “tim” :email “”}

timgilbert12:09:13

I did see there’s a CLJS ticket open for adding support into cljs.reader, http://dev.clojure.org/jira/browse/CLJS-1706

dnolen13:09:23

@dm3 seems unlikely to me - what is the macroexpanded form?

hlolli13:09:32

this code (eliding goog.closure imports) (events/listen (KeyHandler. js/document) EventType.KEY #(.log js/console %)) gives me this deprication warning

keyhandler.js?zx=mx5i5k2m3flw:417 'KeyboardEvent.keyIdentifier' is deprecated and will be removed in M53, around September 2016. See  for more details.
Is the KeyHandler method causing this?

dnolen13:09:56

@bthesorceror hrm, would need a minimal case - there’s quite a few Linux users so someone should be able to repro

dnolen13:09:22

@hlolli looks like it

hlolli13:09:31

hehe ok, its obvious, but strange thing to deprecate. I look for an alternative...

hlolli13:09:27

@sivakumargsk is this a warning or can't you use this library?

sivakumargsk13:09:04

@hlolli yah i got warning

hlolli13:09:56

looking at the source code

#+clj
(defn fmt
  "Formats Date/Number as a string.
  `style` is <:#{date time dt}-#{default short medium long full}>,
  e.g. :date-full, :time-short, etc. (default :date-default)."
  [loc x & [style]] (pfmt x (jvm-locale loc) style))
maybe they didn't give case for #+cljs

sivakumargsk13:09:13

@hlolli so it doesn't work on cljs?

hlolli14:09:00

This library is end of life, also using .cljx, I would either take their functions and implement them yourself, or look at another library.

sivakumargsk14:09:17

@hlolli oh thanks, is their any alternavtive for localization currency formatters libraries in cljs?

dm314:09:16

@dnolen that snippet fails to compile in Cljs, but runs in Clojure. I didn't investigate much further

dnolen14:09:36

@dm3 you’ll need to investigate further

dnolen14:09:46

just because it happens to work in Clojure doesn’t mean anything

dm314:09:09

sure 🙂 just thought someone would see a problem outright

dm314:09:18

as it's pretty simple

dnolen14:09:32

so show the macroexpanded output

dnolen14:09:45

and we’ll see if the code is valid or not

hlolli14:09:10

@sivakumargsk not an expert on currency formatting. But looking at this library tower, they use java libraries [java.text Collator NumberFormat DateFormat]), so what I would do is look into the jungle of javascript libs for something that solves this, didnt see anything in cljsjs on quick look. Maybe you could create a cljsjs package from js-lib that solves this (or ask someone on #cljsjs to help you make a package)?

dm314:09:14

@dnolen - macroexpand-all in Clojure

(defmacro if-zero [v a-val a-clause b-clause] `(if (= ~v 0) (let [~a-val (str ~v)] ~a-clause) ~b-clause))

(clojure.walk/macroexpand-all '(loop [x 1] (if-zero x val (println "got" val) (recur (dec x)))))
(loop*
 [x 1]
 (if
  (clojure.core/= x 0)
  (let* [val (clojure.core/str x)] (println "got" val))
  (recur (dec x))))

dnolen14:09:24

@dm3 that macroexpanded code looks fine and pastes fine

dnolen14:09:41

so something is else is wrong - you need to create a minimal case that demonstrates the problem

dm314:09:44

yep, but the analyzer chokes

dnolen14:09:50

no exernal toolling, no other libraries etc.

dm314:09:02

yeah, this is pretty much the minimal case

dnolen14:09:30

make a minimal case following what I said

dnolen14:09:42

you haven’t stated tooling, environment, compiler version etc.

dnolen14:09:06

all I know is what you said - not how to recreate your problem

dm314:09:18

ok, I see 🙂 where do I go with that then?

dnolen14:09:34

@dm3 have you ever worked through the Quick Start?

dnolen14:09:55

we provide a uberjar that you can use to build simple thing which eliminates the typical environmental variables

dm314:09:49

I assume that's https://github.com/clojure/clojurescript/wiki/Quick-Start? I'll read through and I guess will create an issue if the bug is there

hlolli14:09:05

@sivakumargsk I was looking at something completly else when I stumbled updon this part of goog.closure, maybe something that solves what you are doing? https://google.github.io/closure-library/api/goog.i18n.currency.html

plexus14:09:48

it seems using spec on clojurescript requires having clojure.test.check in your dependencies, even if you're not using the generating functionality

plexus14:09:56

is that correct or am I just holding it wrong?

dnolen14:09:28

@plexus more information please 🙂

plexus14:09:20

ah just a second, I think I know what's happening

plexus14:09:54

ok, so when you (require [clojure.spec.test]) you get

plexus14:09:59

Caused by: clojure.lang.ExceptionInfo: No such namespace: clojure.test.check, could not locate clojure/test/check.cljs, clojure/test/check.cljc, or Closure namespace "clojure.test.check" in file file:/home/arne/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/spec/test.cljs {:tag :cljs/analysis-error}

plexus14:09:49

which I believe is not the case in Clojure (testing it now to make sure I'm not speaking nonsense)

plexus14:09:08

so with only Clojure and Clojurescript loaded

:dependencies [[org.clojure/clojure "1.9.0-alpha12"]
                 [org.clojure/clojurescript "1.9.229" :scope "provided"]]

plexus14:09:37

you can load clojure.spec.test in Clojure, e.g. to use instrument, but not in Clojurescript

plexus14:09:17

not too surprising maybe, since Clojure conditionally loads test.check if it's available, and I guess ClojureScript can't really do that... still seemed useful to point out

dnolen14:09:50

@plexus ok that seems like a bug to me - file an issue in JIRA - thanks

plexus14:09:50

will do 👍

jmmk14:09:08

@dnolen Just watched your talk on "The Next Five Years of ClojureScript" and the part about "externs inference" caught my attention. If you haven't come across it before, I have a small project to generate externs: https://github.com/jmmk/javascript-externs-generator. It's by no means a complete solution, but it works pretty well for the general case (I think people use it mostly with cljsjs/packages). I think looking at the issues (both closed and open) would give a good idea of what it can and can't do, and some open questions about what's even necessary for working with Google Closure. I don't know anything about the Google Closure compiler so I really am just doing what seemed to work, not what's actually necessary or performant.

dnolen14:09:47

@jmmk yes there’s a been quite a few of these kinds of efforts - they seem perfectly reasonable to me. But I think we can do better and just eliminate hand written externs (or seperately generated) for many cases by adding compiler support.

dnolen14:09:08

it may not work out, but there’ll be something a month or so and people can give it a try and we’ll see

plexus14:09:21

@jmmk I looked at your generator. It works by evaluating the code, then inspecting the result, right? @dnolen is that also what you have in mind, or would it be static analysis?

dnolen14:09:54

static analysis but it goes a bit farther

dnolen14:09:28

:infer-externs would trigger a new compiler mode where we check to see if we cannot determine the type of interop calls

dnolen14:09:38

similar to *warn-on-reflection* true in Clojure

dnolen14:09:06

as you add hints for the interop bits - that’s your externs right there

plexus14:09:40

sounds very promising! together with better es6 support from Closure that should unlock a lot of code out there

dnolen14:09:12

yes this is simplified by the fact that interop isn’t actually idiomatic

dnolen14:09:23

method calls and property access are always interop

dnolen14:09:49

so now the compiler can show you all the places where it doesn’t have enough information to generate an extern for interop

borkdude14:09:19

I sometimes have a weird issue with enable-console-print! in this project (boot). We have it in our main file (in dev). But often I need to put it inside a namespace that is about to be reloaded, because else I see nothing.

jmmk14:09:19

How do you know if something is simply undefined (typo) vs interop?

dnolen14:09:59

@jmmk it doesn’t matter if it doesn’t exist or not

dnolen14:09:11

it’s not going to work under advanced compilation anyway 🙂

dnolen14:09:27

at least with externs inference you would get

dnolen14:09:36

Foo.fobar doesn’t exist

dnolen14:09:50

instead of ABZ.sxS doesn’t exist

shyambalu14:09:11

anyone know a good typeahead engine for clojurescript

jmmk14:09:13

I guess I'm not sure if the compiler normally complains on undefined variables - is that not a thing in Clojure?

dnolen14:09:31

@jmmk we’re talking about interop with random libraries

dnolen14:09:39

these things never go through Closure - what is there to warn about?

maxm15:09:20

is there an idiomatic way to import a static .json file? have been digging through Closure Compiler/Clojurescript docs, but have only had success templating those objects into Closure namespace declarations and declaring via :libs.

dnolen15:09:39

@maxm not that I’m aware of

dominicm15:09:24

I thought you could slurp in clojurescript at compile time? Or am I misunderstanding?

dnolen15:09:13

@dominicm right but I was focusing on “idiomatic”, there’s definitely lots of ways to do it

dominicm15:09:38

ah, I see the distinction. Now I understand.

tony.kay16:09:18

Is there updated documentation on the latest support for external library use from cljs? Particularly UMD stuff

tony.kay16:09:19

I’m trying to pull in https://github.com/uber/react-vis which has a lot of deps and a lot of individual files.

tony.kay16:09:53

I found the notes from Google SoC from last year

tony.kay16:09:00

Read Dependencies on cljs website

tony.kay16:09:16

anything else that’s good to know about recent state of affairs?

tony.kay16:09:44

everything I’m finding is no newer than cljs 1.7.x

tony.kay16:09:01

Oh, ChangeLog…I could read that

dnolen16:09:18

Maria Geller’s blog is still the most accurate source of info

dnolen16:09:32

it needs to ported over to a guide (marked alpha) and put on the new site

dnolen16:09:38

somebody should work on that

christianromney17:09:38

@tony.kay if you're not married to that particular lib, [cljsjs/victory "0.9.0-0"] may be worth looking into. then you don't have to deal with the deps

tony.kay17:09:32

Actually, the blog is quite good…and the compiler source is proving enlightening as well.

tony.kay17:09:28

@christianromney Thanks for the tip there…you’re right that that would be a lot easier.

christianromney17:09:16

@tony.kay happy to pass that on. i just stumbled across that library yesterday as it happens

tony.kay17:09:37

I had seen it in JS land, but had not looked for a cljsjs import of it

christianromney17:09:08

i was searching cljsjs for react packages and it popped up

christianromney17:09:39

and in an ironic twist of fate, I now have to go create an extern file lol

tony.kay17:09:14

you probably just saved me several days of work, though. I really liked the looks of vis, but it was going to be a nightmare of deps

christianromney17:09:02

that's awesome! 🙂 hope it works out for you. victory has pretty nice looking graphics also

spieden17:09:51

i recently added “rebass” to cljsjs — need to send a pull request http://jxnblk.com/rebass/

tony.kay17:09:18

@spieden Good one as well!

tony.kay17:09:36

@spieden Is your work on github?

spieden17:09:15

@tony.kay not yet — just breaking ground on releasing stuff open source with work (beyond bug fixes)

spieden17:09:31

i have a CLJS wrapper for it too

tony.kay17:09:16

well, looking forward to it. The more bits we can get integrated the better.

lwhorton17:09:29

does anyone have a link to a blog post or some documentation on the advanced compilation with regards to clojurescript? for example, I find in a heavy js->clj interop piece I’m building, I run into a ton of mangling errors. I’m wondering if someone has gathered together all the “dont do that” about aget vs nth versus (.. obj -foo -bar) vs (.-prop obj) etc?

dnolen17:09:10

@lwhorton there’s nothing specific for ClojureScript because it’s well covered in Closure documentation which is considered required reading

darwin17:09:39

@lwhorton working with string literals which contain backslashes can be, well… surprising, because it might do double escaping

dnolen17:09:18

also people who are still using aget, aset for Object interop - you are going to be completely out of luck if the externs inference stuff lands

darwin17:09:19

#js {“\\” “val”} is wrong, you must do #js {“\\\\” “val”}

dnolen17:09:25

stop using these operations for anything except arrays

lwhorton18:09:06

something like (aget (.-series chart) 0) is bad because it will become some_ns.chart.series[(0)] which will :advanced to a.b[0] (or something like it). but what, then, should we use without (aget obj “prop” “prop”) if (.. obj -prop -prop) and (.-prop obj) won’t pass :advanced properly?

darwin18:09:54

compiles down to goog.object.get/set

dnolen18:09:03

@lwhorton the goog.object namespace

dnolen18:09:32

@lwhorton but in your example series looks like an array so that’s fine

dnolen18:09:45

what’s wrong is (.-series chart) if there is no extern

dnolen18:09:00

(goog.object/get chart “series”)

lwhorton18:09:31

i see.. alright, i’ve got a lot of cleaning up to do 😕

dnolen18:09:15

you will save yourself a lot of trouble if you go through this

alex-glv19:09:31

.. maybe a stupid question about Om and React. Do Om and React implement different rendering loops? Also, in React, state is defined per component, in Om state is one global var, but also one can pass initial state to a component, how do they compare?

dnolen19:09:12

@alex-glv there’s an #om channel

alex-glv19:09:36

Awesome, will pass it there.

jiangts22:09:37

are foreign deps supported by GCC, or are foreign deps just something that the CLJS compiler adds as a convenience, and those deps are prepended before the GCC compiled js

dnolen22:09:50

@jiangts: “foreign” means incompatible with GCC

dnolen22:09:04

however ...

dnolen22:09:54

this has been modified a bit with the ability to specify the module type per foreign dep - in that case the incompatible thing will be compiled into a compatible thing

dnolen22:09:45

but yes, prior to that foreign meant can’t go through GCC so will be prepended

jiangts22:09:18

oh, specifying :module-type will result in the code getting properly consumed by GCC?

jiangts22:09:16

I watched your recent talk on youtube at clojuTRE and was also confused by this. Why does GCC impose rules on js style for simple/advanced compilation if it can consume any module format?

dnolen22:09:35

you need to follow pretty strict rules about style if you want advanced optimization to really work

dnolen22:09:59

yes about :module-type, but its’ an alpha feature, there’s more work that needs to be done

jiangts22:09:20

so to be clear, say it's a :commonjs module and it doesn't follow any of the rules for advanced optimization. what does making such a package GCC compatible mean? Since the package doesn't follow the strict rules, I'd expect things like DCE to be impossible on such a module.

dnolen22:09:34

not necessarily

dnolen22:09:38

there’s just no guarantee

dnolen22:09:04

@jiangts I recommend reading Maria Geller’s blog posts if you’re really interested in this stuff

dnolen22:09:13

I don’t have anything more to say about it then she already has