Fork me on GitHub
#shadow-cljs
<
2017-11-06
>
thheller10:11:49

@mhuebert I think I covered most cases for externs inference now. if you can please test [email protected].

thheller10:11:17

added :infer-externs :auto to turn it on for every file in the project itself

thheller10:11:47

true still requires the (set! *warn-on-infer* true), :auto just does it for files (not jars), :all for everything but thats not safe

thheller10:11:01

it also no longer warns about any properties already defined in externs

thheller10:11:12

so you could probably remove a whole bunch of annotations you already did

thheller10:11:36

eg. (doto ^js out (.push (-to-element el)))) this doesn’t need to be annotated anymore since .push is defined in Array externs

eveko12:11:48

How can I reference npm deps in my cljs?

mhuebert14:11:21

@thheller I really like the idea of these obvious cases (like .push) being taken care of

mhuebert14:11:15

I am getting this error:

-> Closure - Optimizing ...
IllegalArgumentException: Don't know how to create ISeq from: com.google.javascript.jscomp.SourceFile$Preloaded
	clojure.lang.RT.seqFrom (RT.java:550)
	clojure.lang.RT.seq (RT.java:530)
	clojure.core/seq--5124 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--7829 (protocols.clj:75)
	clojure.core.protocols/fn--7829 (protocols.clj:75)
	clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13)
	clojure.core/reduce (core.clj:6748)
	clojure.core/into (core.clj:6815)
	clojure.core/into (core.clj:6807)
	shadow.build.closure/load-externs (closure.clj:392)

mhuebert14:11:10

and can confirm it happens in 2.0.60. when i reverted to 2.0.59, it kept happening until I deleted target

thheller14:11:58

@mhuebert oops, fixen in 2.0.61

thheller14:11:44

@eveko usually you need to first install the dependency via npm, say npm install thing. then in your (ns your.app (:require ["thing" :as thing]))

thheller14:11:25

has a short info how to translate require/import from JS

eveko14:11:01

I have been trying to get blueprint to work, but can't get it to import into the ns

thheller14:11:47

import { Intent, Spinner, DatePickerFactory } from "@blueprintjs/core";

eveko14:11:12

for example

thheller14:11:36

(:require ["@blueprintjs/core" :as bp :refer (Intent Spinner)])

thheller14:11:33

some packages are weird and cause errors on imports, I want to know about those

thheller14:11:38

otherwise it should just work

thheller14:11:07

can also use bp/Intent, no need to use the :refer

eveko14:11:23

In my case I want to fiddle with components

eveko14:11:27

(def button (r/adapt-react-class js/bp.ButtonFactory))

thheller14:11:34

without js/

thheller14:11:49

bp/ButtonFactory

thheller14:11:03

assuming you have bp used as :as

eveko14:11:39

now I get at least a usefull error

eveko14:11:45

now that ns is correct

eveko14:11:54

missing js librarys

eveko14:11:25

ok build succed now time to run the server and see if reagent manages to do anything remotely sane

thheller14:11:02

@dustingetz you ask tough questions 🙂 you could probably look at https://github.com/lambdaisland/npmdemo to get a glimpse of whats different

thheller14:11:16

that has config for all the build tools and shadow-cljs is among them

thheller14:11:54

I like to stay away from directly comparing to other tools myself since I haven’t used any of them

eveko14:11:01

btw the live reloading plays real nice with dotnet core

thheller14:11:15

I’ll write a more thorough answer on reddit

thheller14:11:34

nice, good to know

thheller20:11:01

I started putting together a quickstart for shadow-cljs recently https://github.com/shadow-cljs/quickstart-browser

thheller20:11:45

what do you think is easier for beginners? should I just stick with the command line or use the REPL?

thheller20:11:04

(shadow/watch :app) vs npx shadow-cljs watch app

thheller20:11:27

I feel like using both in the same example might be too confusing

mitchelkuijpers20:11:49

Damn just tried out shadow-cljs for the first time. I wanted to consume certain npm-modules which I never got working with the new npm-deps stuff. And I just tried it out with shadow-cljs and it somehow just works! Pretty damn cool

thheller20:11:38

nice to hear 🙂

mitchelkuijpers20:11:53

I do have one question about the release task does it use advanced compilation? Because it does not see to me that it does

thheller20:11:35

it depends on the :target you are using. :browser defaults to :advanced, the node targets default to :simple

thheller20:11:20

but since most stuff from npm doesn’t work with :advanced it will only use :simple for that

thheller20:11:30

so you are getting both basically

mitchelkuijpers20:11:52

Ah so if you add npm-deps it will use simple for everything or only for the node deps and then the rest with advanced?

thheller20:11:09

simple for node deps only, advanced for CLJS+Closure

mitchelkuijpers20:11:41

Damn that is cool

thheller20:11:55

you can also try advanced for everything by setting :js-options {:js-provider :closure} but as you experienced that doesn’t work all too well 😉

mitchelkuijpers20:11:41

Very true, right now we have some webpack build and then we add stuff to window which I hate so this is already 1000 times better

thheller20:11:35

from a technical perspective I pretty much do the same thing webpack does, just better integrated 😉

mitchelkuijpers21:11:30

Still love not having two tools ^^

thheller22:11:49

blogged about the externs work I did the last few days