This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-30
Channels
- # bangalore-clj (1)
- # beginners (104)
- # boot (207)
- # cider (173)
- # cljs-dev (157)
- # cljsjs (1)
- # cljsrn (51)
- # clojure (196)
- # clojure-berlin (1)
- # clojure-chicago (1)
- # clojure-italy (4)
- # clojure-new-zealand (1)
- # clojure-nl (1)
- # clojure-russia (28)
- # clojure-spec (17)
- # clojure-uk (73)
- # clojured (13)
- # clojurescript (110)
- # core-async (4)
- # datascript (25)
- # datomic (92)
- # editors (1)
- # emacs (157)
- # events (4)
- # hoplon (16)
- # klipse (74)
- # lein-figwheel (10)
- # leiningen (2)
- # lumo (13)
- # off-topic (78)
- # om (3)
- # om-next (3)
- # onyx (14)
- # protorepl (1)
- # re-frame (17)
- # reagent (23)
- # remote-jobs (1)
- # ring-swagger (33)
- # schema (2)
- # slack-help (3)
- # spacemacs (7)
- # testing (1)
- # yada (7)
@alun Cloverage doesn’t do ClojureScript, but should be not that hard to port to it since it’s a source transformation
I have been playing with the new externs inference feature. Does anyone know how to typehint this correctly?
So I learned in my pursuit of secure sockets and such for my cljs application..... always use HTTPS. That way, all communication is within an encrypted layer. On top of that, you can do logins and the initial over-the-wire username/pw combination can be considered secure. Once you have passed a token back to the client that they send on every request, you can also encorporate some "is this the same IP as before?" and make sure tokens expire over time so that your site stays secure even if token info is somehow compromised
;; conformer
(defn coll->set [x]
(cond
(set? x) x
(coll? x) (set x)
:else :clojure.spec/invalid))
(s/def ::my-spec-coll (s/coll-of ::my-spec :kind (s/conformer coll->set) :into #{}))
I'm seeing a problem with array-seq
in advanced compilation mode. Works fine with no optimizations but in production I keep getting Cannot read property 'length' of undefined
exceptions.
It's within a this-as
macro that I'm calling array-seq
@danielstockton the array you call array-seq
on: does it come from a javascript option which might need externs? ie. (array-seq (.getThatArray someJsObject))
@thheller yes, thats probably it.
What does that do exactly? Emit certain warnings during compilation?
I'll just try it out..
it'll mangle names, but in a predictable way
The lib i'm using is a cljsjs package, does that mean they missed an extern?
@pesterhazy Does that mean it's not something I want turned on all the time for my production builds? Are there disadvantages to it being true?
it may not mean that, e.g. if it's in a callback
no you only turn it on during dev time, temporarily, to figure out what's going on
Ah right, ok. It is in a callback, would adding ^:export metadata help?
no I don't think so
(aget this "field")
?
probably best to just use goog.object/get instead of .-
notation
mhm ok, thanks
IMO every call to .-
needs to vetted to see if it'll continue to work during adv comp
personally I mostly resort to goog.object/get by default these days
Ok, thanks for the help, that sorted it.
The cljs.analyzer.api/ns-publics
returns is not vars. I want to filter vars by meta data.
argh ... cljsbuild fails on travis-ci with Can't redefine a constant at line 61 ...
, but it works locally. I've fought this issue once, but it went away, now it came back out of the blue 😞
hi, in a regeant project template, I've added [org.clojure/core.async "0.2.395"] in my project.clj file, and then in core.cljs I require [cljs-http.client :as http] [cljs.core.async :refer [<!]]
running lein figwheel in project root, I get this error: No such namespace: cljs-http.client, could not locate cljs_http/client.cljs, cljs_http/client.cljc, or Closure namespace "cljs-http.client"
@isaac you can use it to return vars, cljs.test
does this trick as well - you might want to look there for ideas
FYI: I just built ClojureScript app with React directly from NPM and there seem to be a bug, you can read more about it here https://github.com/facebook/react/issues/8887
@roman01la: have you tried your cljs-npm-test under none or simple optimizations?
I get an error which is also of the form of the issue you opened
this._instantiateReactComponent
is not a function
@anmonteiro No, I didn’t. But I’m setting up dev build at the moment, so we’ll see
It's not specific to your repo btw, happens whenever you consume React from NPM
ok, I’m doing that on the app at work
No idea why it works in advanced mode
And not in other modes
hihi. can you point me to routing examples in case where I have subcomponents? (menu, submenu) (still learning react)
not sure how to choose which component from root menu to render, when I have subcomponent of the submenu =/
@anmonteiro for some reason I couldn’t even make figwheel see a foreign lib js module which requires stuff from NPM cc @bhauman I’m using [figwheel-sidecar "0.5.9"]
for the infer-externs
feature of 1.9.456
, It seems failed to infer my project.
https://github.com/DogLooksGood/HiccupMacroParser
Is there any tips for how to write code that can get correct externs inference?
It seems like the problem is related to this line.
(.setState this# new-state#)
https://github.com/DogLooksGood/HiccupMacroParser/blob/master/src/one/macros.cljc#L54
this.setState
has been compressed to something like c.Za
.@doglooksgood externs inference isn’t automatic in that way - have you read through the guide?
it works via warning on missing type-hints and uses those type hints to compute externs
I walk through the guide and start adding type hints. all warning solved except this:
(fn [db]
(let [f-type (:filter db)
f (case f-type
:all identity
:active (complement :completed?)
:completed :completed?)]
(->> (get db :todos)
(filter f))))
WARNING: Cannot infer target type in expression (. f-type -fqn)
there's no javascript library interop.@doglooksgood hrm thanks will take a look at that- but yes safe to ignore
quick question: In :cljsbuild configuration I had to prepend :asset-path "js/compiled/out" with leading "/", otherwise when my server url is not root, I was getting figwheel warning, and it tried to find my js modules within current url subpath. so now my :asset-path is "/js/compiled/out". Am I doing it right?
(but official documentation says "js/compiled/out", as well as chestnut configuration sets it so? Sure it was corrected before, and I couldn't encountered the problem first?)
@leov No you're good, that's one of the first things I change. I've seen this question a few times and this is the correct answer to your problem
If anyone is interested, I am trying initialize an open source project that facilitates building campaigns for public office in a transparent and less costly manner. There are more details in the #political-canvas channel
did anybody else get the cljs.spec
conformer
errors on 1.9.456 that I mentioned last night?
for reference:
I just upgraded to cljs 1.9.456 and my conformer spec started throwing errors
[11:04]
error is cljs.spec.spec_impl.call(...).call is not a function
[11:06]
;; conformer
(defn coll->set [x]
(cond
(set? x) x
(coll? x) (set x)
:else :clojure.spec/invalid))
(s/def ::my-spec-coll (s/coll-of ::my-spec :kind (s/conformer coll->set) :into #{}))
@dnolen hmm, ok. In my actual codebase it’s basically
(defn coll->set [x]
(cond
(set? x) x
(coll? x) (set x)
:else :clojure.spec/invalid))
(s/def ::my-spec int?)
(s/def ::my-spec-coll (s/coll-of ::my-spec :kind (s/conformer coll->set) :into #{}))
(s/def ::my-spec-wrapper (s/keys :req-un [::my-spec-coll]))
(s/valid? ::my-spec-wrapper {:my-spec-coll [1 2 3]})
and on the call to s/valid?
I get the cljs.spec.spec_impl.call(...).call is not a function
error
aha, didn’t realize that. And I’ll play around a bit more in my repl to see if I can isolate the problem a bit better
(defn coll->set [x]
(cond
(set? x) x
(coll? x) (set x)
:else ::s/invalid))
(s/def ::set-ints (s/coll-of int? :kind (s/conformer coll->set) :into #{}))
(s/def ::vec-ints (s/coll-of int? :kind vector? :into []))
(try
(s/valid? ::set-ints [1 2 3])
(catch js/Object e
(js/console.error e)))
(s/valid? ::vec-ints [1 2 3])
prints
TypeError: cljs.spec.spec_impl.call(...).call is not a function
at eval (eval at figwheel$client$utils$eval_helper (utils.cljs?rel=1485763033743:57), <anonymous>:2:151)
at cljs.spec.every_impl.cljs$core$IFn$_invoke$arity$4.cljs.spec.t_cljs$spec92144.cljs$spec$Spec$conform_STAR_$arity$2 (spec.cljs?rel=1485763028944:844)
at cljs$spec$conform_STAR_ (spec.cljs?rel=1485763028944:40)
at Function.cljs.spec.valid_QMARK_.cljs$core$IFn$_invoke$arity$2 (spec.cljs?rel=1485763028944:357)
at cljs$spec$valid_QMARK_ (spec.cljs?rel=1485763028944:353)
at eval (eval at figwheel$client$utils$eval_helper (utils.cljs?rel=1485763033743:57), <anonymous>:1:137)
at eval (eval at figwheel$client$utils$eval_helper (utils.cljs?rel=1485763033743:57), <anonymous>:9:4)
at eval (eval at figwheel$client$utils$eval_helper (utils.cljs?rel=1485763033743:57), <anonymous>:17:3)
at eval (eval at figwheel$client$utils$eval_helper (utils.cljs?rel=1485763033743:57), <anonymous>:22:4)
at figwheel$client$utils$eval_helper (utils.cljs?rel=1485763033743:57)
TypeError: cljs.spec.spec_impl.call(...).call is not a function
at core.cljs:10
at cljs.spec.every_impl.cljs$core$IFn$_invoke$arity$4.cljs.spec.t_cljs$spec9434.cljs$spec$Spec$conform_STAR_$arity$2 (spec.cljs:844)
at cljs$spec$conform_STAR_ (spec.cljs:40)
at Function.cljs.spec.valid_QMARK_.cljs$core$IFn$_invoke$arity$2 (spec.cljs:357)
at cljs$spec$valid_QMARK_ (spec.cljs:353)
at core.cljs:13
the contents of the file are simply
(ns repro.core
(:require [cljs.spec :as s]))
(defn coll->set [x]
(cond
(set? x) x
(coll? x) (set x)
:else ::s/invalid))
(s/def ::set-ints (s/coll-of int? :kind (s/conformer coll->set) :into #{}))
(s/def ::vec-ints (s/coll-of int? :kind vector? :into []))
(try
(s/valid? ::set-ints [1 2 3])
(catch js/Object e
(js/console.error e)))
(s/valid? ::vec-ints [1 2 3])
so download that cljs jar file and run it like java -cp cljs.jar:src clojure.main release.clj
?
TypeError: cljs.spec.spec_impl.call(...).call is not a function
at core.cljs:10
at cljs.spec.every_impl.cljs$core$IFn$_invoke$arity$4.cljs.spec.t_cljs$spec860.cljs$spec$Spec$conform_STAR_$arity$2 (spec.cljs:844)
at cljs$spec$conform_STAR_ (spec.cljs:40)
at Function.cljs.spec.valid_QMARK_.cljs$core$IFn$_invoke$arity$2 (spec.cljs:357)
at cljs$spec$valid_QMARK_ (spec.cljs:353)
at core.cljs:13
@jiangts great open an issue with exact steps http://dev.clojure.org/jira/browse/CLJS
and I will take a look later - if I can repro will definitely get resolved by the next release
Anyone got a suggestion for a library to do selectors on Hiccup? I know of https://github.com/cjohansen/hiccup-find, but it doesn’t work with long form elements like [:div {:class “foo”}]
, only CSS-selector style like [:div.foo]
.
I suspect that this functionality has to exist in some library somewhere, even as a support function...