This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-17
Channels
- # admin-announcements (4)
- # boot (93)
- # cider (4)
- # cljsrn (61)
- # clojure (137)
- # clojure-austin (2)
- # clojure-brasil (2)
- # clojure-dev (11)
- # clojure-dusseldorf (10)
- # clojure-greece (245)
- # clojure-russia (37)
- # clojure-spec (60)
- # clojure-taiwan (1)
- # clojure-uk (24)
- # clojurescript (36)
- # cursive (18)
- # datomic (20)
- # emacs (20)
- # funcool (1)
- # hoplon (29)
- # jobs (1)
- # keechma (1)
- # lein-figwheel (1)
- # leiningen (1)
- # off-topic (3)
- # om (10)
- # om-next (1)
- # onyx (60)
- # other-languages (14)
- # planck (26)
- # random (3)
- # re-frame (21)
- # ring (2)
- # spacemacs (8)
- # specter (56)
- # spirituality-ethics (2)
- # uncomplicate (1)
- # untangled (68)
- # yada (3)
can anyone point me at something that can be used in real-life project that would allow easily include any piece of javascript from npm? Maybe something that utilizes webpack? Basically what I’m struggling with is to take something like https://www.npmjs.com/package/react-daterange-picker and be able to use it in Om-next project
@dnolen: not sure if you are aware of it, I'm was testing version 1.9.70
here and this is erroring: (inst? (js/Date.))
with #object[TypeError TypeError: Cannot read property 'call' of undefined]
same trying to (inst-ms (js/Date.))
or (satisfies? Inst (js/Date.))
sorry, my bad, forgot to restart my browser after updating the cljs, all working fine
@ag: https://github.com/RyanMcG/lein-npm looks promising, here’s an example repo https://github.com/kissaten/cljs-lein-npm-example.
Hey everyone. Just thought I'd drop a short note on strange behaviour in subvec. In clojure
(def foo (subvec nil 1))
CompilerException java.lang.IndexOutOfBoundsException, compiling:(form-init4645269128697935824.clj:1:10)
(def foo (subvec nil nil))
CompilerException java.lang.NullPointerException, compiling:(form-init4645269128697935824.clj:1:10)
In ClojureScript:
(def foo (subvec nil 1))
#object[Error Error: Index out of bounds]
cljs.core/build-subvec (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5316:16)
Function.cljs.core.subvec.cljs$core$IFn$_invoke$arity$3 (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5328:7)
Function.cljs.core.subvec.cljs$core$IFn$_invoke$arity$2 (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5326:7)
cljs$core$subvec (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:5319:1)
=> nil
(def foo (subvec nil nil))
=> #'user/foo
And doing anything with foo afterwards fails:
foo
#object[Error Error: No protocol method IIndexed.-nth defined for type null: ]
cljs.core/missing-protocol (jar:file:/Users/stoyle/.m2/repository/org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar!/cljs/core.cljs:264:4)
I'm filtering a long list of numbers, and want to get rid of all NaN
in there. The problem is that (= NaN NaN) => false
. How can I test a JS/Clojurescript number to be a REAL number?
(on a related note, Wat: https://www.destroyallsoftware.com/talks/wat)
how about https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/isNaN ?
@metametadata: thanks! You're so right. (I'd like some curry with that... Sorry, it had to be done)
@alfkristian: looks like a minor bug, feel free to file that in JIRA
Will do!
I'm using Leaflet.js (javascript library to be able to pan and zoom geographical maps) and getting this error: main.js:1977 Uncaught TypeError: L.map(...).Sk is not a function
, but only with :optimizations :advanced
. With the error you can't see the map at all. It worked fine with :whitespace
. I know the source code that is at fault, but I don't know the reason for the error. Has anyone seen this before?
for JS that doesn’t go through the Closure pipeline (random 3rd party JS library) you need to provide externs
No - just copied from rete4flights. Looking at blade now. Will look at CLJSJS too thanks.
yeah if you don’t want to supply your own externs I would look for a CLJSJS versions of the lib you want to use
Btw. regarding the need for externs, has anyone tested what size and performance benefits does using foo.bar
form for JS calls and properties have? Scala.js uses foo["bar"]
form which means they don't need externs (it is not perfect solution either: https://github.com/scala-js/scala-js/issues/761#issuecomment-46776063)
@juhoteperi: not aware that anyone has, would be interesting to see that in large projects - also the auto-generating externs idea is still sitting around for someone to tackle
Sure, it would be possible to automatically generate externs in Cljsjs tooling or Cljs compiler, but the approach of evaluating the code and inspecting the object doesn't work on ~10% of libs
So I'm not sure that is the best solution
One solution would be to use Fence, or something similar: https://github.com/myguidingstar/fence
Fence readme also says that foo["bar"]
will be optimized to foo.bar
, so there won't be size differencen for external calls
So the real problem is to differentiate calls to Closure libs (which need to be mangled) and foreign libs
Don't we use externs, so we can rename/get rid of, parts of libraries? Wouldn't we lose that by doing ["bar"]?
Dead code elimination doesn't work with foreign libs, externs don't affect that
Clojure: (clojure.string/split "qwe" #"") ; => ["q" "w" "e"]
✅. ClojureScript: (clojure.string/split "qwe" #"") ; => ["" "q" "w" "e"]
❌, note new first element empty string. http://dev.clojure.org/jira/browse/CLJ-1312 found this to be happening on Java 7 but fixed in Java 8 and was thus closed—but it remained a Clojure-only issue, no mention of ClojureScript. I'm also looking at http://dev.clojure.org/jira/browse/CLJS-532 and http://dev.clojure.org/jira/browse/CLJS-1590 where specific divergences between Clojure/Script split
are being fixed. Should I try to reopen 1312 because the difference exists between clj/cljs, or open a new ticket, or any other advice?
@fasiha: the advice would be to determine what the source of the divergence actually is
@dnolen: that makes sense. No, JavaScript does the right thing: "qwe".split("") // => ["q", "w", "e"]
. Maybe some code in ClojureScript that was added to synchronize clj & cljs behavior may be inadvertently introducing the empty string. Will look.
ClojureScript 1.9.76 released https://groups.google.com/d/msg/clojurescript/MKNhxz7DYuE/sB93k4r8AAAJ