This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-23
Channels
- # alda (1)
- # beginners (26)
- # boot (88)
- # carry (2)
- # cider (6)
- # clara (6)
- # cljs-dev (43)
- # cljsrn (14)
- # clojure (48)
- # clojure-belgium (2)
- # clojure-czech (4)
- # clojure-dev (1)
- # clojure-dusseldorf (7)
- # clojure-japan (1)
- # clojure-russia (55)
- # clojure-spec (65)
- # clojure-taiwan (1)
- # clojure-uk (28)
- # clojurescript (154)
- # cursive (5)
- # datomic (1)
- # editors (2)
- # emacs (29)
- # funcool (1)
- # jobs (3)
- # lambdaisland (5)
- # leiningen (1)
- # luminus (2)
- # new-channels (1)
- # off-topic (17)
- # om (18)
- # om-next (10)
- # onyx (24)
- # parinfer (14)
- # pedestal (4)
- # planck (3)
- # re-frame (69)
- # reactive (2)
- # reagent (3)
- # schema (2)
- # spacemacs (2)
- # sql (13)
- # vim (11)
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
Anyone knows how to represent ES7 static properties in cljs?
Figure it out, it’s my problem.
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.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
@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
using
(:require [re-frisk.core :refer-macros [def-view]])
instead
(:require-macros [re-frisk.core :refer [def-view]]))
works fineI 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
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 “
I did see there’s a CLJS ticket open for adding support into cljs.reader, http://dev.clojure.org/jira/browse/CLJS-1706
@timgilbert tools.reader
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?@bthesorceror hrm, would need a minimal case - there’s quite a few Linux users so someone should be able to repro
@sivakumargsk is this a warning or can't you use this library?
@hlolli yah i got warning
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@hlolli so it doesn't work on cljs?
This library is end of life, also using .cljx, I would either take their functions and implement them yourself, or look at another library.
@hlolli oh thanks, is their any alternavtive for localization currency formatters libraries in cljs?
@dnolen that snippet fails to compile in Cljs, but runs in Clojure. I didn't investigate much further
@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)?
@hlolli Ok thanks.
@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))))
so something is else is wrong - you need to create a minimal case that demonstrates the problem
we provide a uberjar that you can use to build simple thing which eliminates the typical environmental variables
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
@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
it seems using spec on clojurescript requires having clojure.test.check in your dependencies, even if you're not using the generating functionality
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}
which I believe is not the case in Clojure (testing it now to make sure I'm not speaking nonsense)
so with only Clojure and Clojurescript loaded
:dependencies [[org.clojure/clojure "1.9.0-alpha12"]
[org.clojure/clojurescript "1.9.229" :scope "provided"]]
you can load clojure.spec.test
in Clojure, e.g. to use instrument
, but not in Clojurescript
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
@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.
@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.
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
@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?
:infer-externs
would trigger a new compiler mode where we check to see if we cannot determine the type of interop calls
sounds very promising! together with better es6 support from Closure that should unlock a lot of code out there
so now the compiler can show you all the places where it doesn’t have enough information to generate an extern for interop
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.
I guess I'm not sure if the compiler normally complains on undefined variables - is that not a thing in Clojure?
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
.
I thought you could slurp in clojurescript at compile time? Or am I misunderstanding?
@dominicm right but I was focusing on “idiomatic”, there’s definitely lots of ways to do it
Is there updated documentation on the latest support for external library use from cljs? Particularly UMD stuff
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.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
Actually, the blog is quite good…and the compiler source is proving enlightening as well.
@christianromney Thanks for the tip there…you’re right that that would be a lot easier.
@tony.kay happy to pass that on. i just stumbled across that library yesterday as it happens
i was searching cljsjs for react packages and it popped up
and in an ironic twist of fate, I now have to go create an extern file lol
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
that's awesome! 🙂 hope it works out for you. victory has pretty nice looking graphics also
i recently added “rebass” to cljsjs — need to send a pull request http://jxnblk.com/rebass/
@tony.kay not yet — just breaking ground on releasing stuff open source with work (beyond bug fixes)
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?
@lwhorton there’s nothing specific for ClojureScript because it’s well covered in Closure documentation which is considered required reading
@lwhorton working with string literals which contain backslashes can be, well… surprising, because it might do double escaping
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
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?
shameless plug: https://github.com/binaryage/cljs-oops
this is essential reading https://developers.google.com/closure/compiler/docs/api-tutorial3
.. 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?
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
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
oh, specifying :module-type
will result in the code getting properly consumed by GCC?
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?
you need to follow pretty strict rules about style if you want advanced optimization to really work
yes about :module-type
, but its’ an alpha feature, there’s more work that needs to be done
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.