Fork me on GitHub
#clojurescript
<
2016-06-17
>
ag00:06:35

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

wilkerlucio00:06:22

@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]

wilkerlucio00:06:21

same trying to (inst-ms (js/Date.)) or (satisfies? Inst (js/Date.))

wilkerlucio00:06:07

sorry, my bad, forgot to restart my browser after updating the cljs, all working fine

alfkristian06:06:08

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

alfkristian06:06:42

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)

codemartin09:06:54

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)

codemartin09:06:01

@metametadata: thanks! You're so right. (I'd like some curry with that... Sorry, it had to be done)

dnolen13:06:04

@alfkristian: looks like a minor bug, feel free to file that in JIRA

cjmurphy13:06:34

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?

dnolen13:06:31

@cjmurphy: advanced optimizations munges names

dnolen13:06:51

for JS that doesn’t go through the Closure pipeline (random 3rd party JS library) you need to provide externs

dnolen13:06:29

@cjmurphy: are you using the CLJSJS version of leaflet?

cjmurphy13:06:23

No - just copied from rete4flights. Looking at blade now. Will look at CLJSJS too thanks.

dnolen13:06:35

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

juhoteperi14:06:55

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)

dnolen15:06:02

@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

juhoteperi15:06:46

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

juhoteperi15:06:53

So I'm not sure that is the best solution

juhoteperi15:06:30

One solution would be to use Fence, or something similar: https://github.com/myguidingstar/fence

juhoteperi15:06:51

Fence readme also says that foo["bar"] will be optimized to foo.bar, so there won't be size differencen for external calls

juhoteperi15:06:28

So the real problem is to differentiate calls to Closure libs (which need to be mangled) and foreign libs

dominicm15:06:41

Don't we use externs, so we can rename/get rid of, parts of libraries? Wouldn't we lose that by doing ["bar"]?

juhoteperi15:06:55

Dead code elimination doesn't work with foreign libs, externs don't affect that

dominicm15:06:29

Oh, I thought it did. Makes sense then.

fasiha17:06:35

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?

dnolen17:06:02

@fasiha: the advice would be to determine what the source of the divergence actually is

dnolen17:06:23

if we’re bottoming out in JavaScript behavior we’re not going to do anything about it

fasiha17:06:15

@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.

dnolen18:06:24

@fasiha: great, thanks for looking into it

dnolen20:06:22

includes all the latest relevant changes in Clojure 1.9.0-alpha7