Fork me on GitHub
#shadow-cljs
<
2019-09-26
>
Mikko Koski07:09:51

Would it make sense to add a top-level config, something like :ignore-warnings-in-ns #{ns.*} instead of adding the :ignore in :warnings-as-errors? We also have a dep that causes warnings and we can't really do anything about them, so I'd prefer just to ignore those warnings altogether and then let all other warnings throw errors.

thheller07:09:59

I was thinking about adding something like :defaults {:compiler-options ...} at the top level. so config that applies to all builds

šŸ‘Œ 4
joshkh17:09:58

given the popularity of react-bootstrap, i'm hoping someone can help. when i require react-bootstrap:

(ns myproject.core
  (:require ["react-bootstrap" :as bs]))
i get the following runtime exception:
TypeError: (0 , _uncontrollable.default) is not a function
i think last time i asked about this error regarding another npm module, the cause had to do with a transitive dependency conflict?

thheller17:09:28

yes, that is caused by a version conflict

joshkh17:09:50

i've tried with both 0.8.0 and 0.9.0-rc1 in my shadow-cljs.edn :dependencies

joshkh17:09:57

hmm. and like last time, triggering a hot-reload fixes the problem

thheller17:09:09

thats a version conflict on the npm package not the CLJS side

thheller17:09:13

so package.json

miguelb17:09:26

Hi everyone, still relatively new to cljs and shadow but I just wanted to confirm something, given this code:

(ns demo.foo)
(defn hello [who]
  (str "Hello, " who "!"))
(defn generate-exports []
  #js {:hello hello})
and this config
:builds
 {:lib {:target      :node-library
        :output-to   "package/lib.js"
        :exports-fn  demo.foo/generate-exports}}
and this command: shadow-cljs release lib Iā€™m getting a ā€œlib.jsā€ size of 98k. Does that seem right?

joshkh17:09:42

got it. and i think last time you said there's no easy solution, as juggling multiple versions on the NPM side is crazytalk

joshkh17:09:49

@miguelb that's pretty small all things considered, and way smaller when automatically gzipped by the server/browser.

thheller17:09:26

@miguelb yes. there isn't much use in checking the size of dummy code since most of it is cljs.core and stuff

thheller17:09:47

think of it like that lib included immutable-js + lodash or so

miguelb17:09:57

ah ok, Iā€™m starting to evaluate writing libraries in cljs for use at work so I wanted to see how much overhead I would be bringing along

miguelb17:09:24

@joshkh @thheller thanks again for the input

joshkh17:09:38

@thheller i think last time you did some digging on my behalf. any advice for identifying the conflict myself?

lilactown17:09:05

@miguelb IMO writing libs in CLJS for JS is not tenable right now, exactly because most of the time you donā€™t want the overhead of CLJS core data structures and standard library in your library code

joshkh17:09:15

^ even when the target is a nodejs library? is 98kb a big deal server-side?

miguelb17:09:51

sorry, not server side

miguelb17:09:01

it would be for browser

miguelb17:09:47

though none of the libraries I was thinking about doing have any browser specific in them.

lilactown17:09:00

@joshkh even for Node.js I would ask: why? writing libraries in CLJS is not itā€™s forte

lilactown17:09:51

Iā€™m often far more tempted to write libs in JS and a small wrapper in CLJS, than the other way around

lilactown17:09:28

CLJS and itā€™s standard library and data structures really only shine in application development

joshkh17:09:07

thanks for sharing, and i do agree that writing one-off cljs libs for any js based project is not ideal.

lilactown17:09:20

itā€™s tough when you want to transition to using Clojure but your app is written in JS already

joshkh17:09:24

that being said i've had success replacing large portions of js based projects with self contained cljs projects, but they were full apps with their own api, and ended up being the same file size in the end.

miguelb17:09:49

@lilactown thatā€™s exactly the situation iā€™m in

thheller17:09:36

@lilactown I disagree. you can write libraries pretty well in CLJS. just not those typical micro libraries with one function in them. writing something bigger that would bring in something like immutable-js+lodash etc in JS wouldn't be much different.

lilactown17:09:13

yeah I wouldnā€™t adopt a library that brought in immutable.js or (probably) lodash either. IMO those are app-level abstractions that arenā€™t really useful in a library

lilactown17:09:21

itā€™s the same as a library including core.async. Donā€™t do that to me! Iā€™ll use core.async in my app and bridge the gap if I need your lib, or maybe install a peer lib that provides that interop

thheller17:09:08

core.async I agree but for me that pretty much also counts for Promise stuff

thheller17:09:32

I can totally see big libs using immutable-js or so internally. like a database implementation or something like apollo

thheller17:09:58

stuff that exposes a "normal" API and just does a lot of stuff behind the scenes but doesn't actually expose immutable-js to the outside

thheller17:09:10

but overall it is best to use CLJS for CLJS and don't do too much JS šŸ˜‰

lilactown17:09:56

I borderline agree for those larger libs

lilactown17:09:15

something like immutable-js (or CLJSā€™ data) is likely to be too general purpose for a lot of cases too

lilactown17:09:28

but the scale does start to tip in the favorable direction I agree

miguelb17:09:42

so is there hope to gradually changing over a larger JS app with CLJS?

thheller17:09:49

depends on what you are changing from. if you have to go back and forth all the time it probably isn't worth it

thheller17:09:50

the problem only comes when you include multiple of those libs in one JS project

thheller17:09:48

@joshkh if you wouldn't mind asking that question again somewhere others can find it too (http://ask.clojure.org, stackoverflow or so)

thheller17:09:00

I can give you some hints how to track it down

joshkh17:09:04

great idea, and thanks @thheller. i was already finding it frustrating not being able to find my previous question on slack.

thheller17:09:43

indeed. I know I tracked it down last time but also can't remember

kanwei18:09:06

Trying to get react-select to work but it's not

kanwei18:09:08

/js/cljs-runtime/shadow.js.js:36 shadow-cljs - failed to load module$node_modules$$emotion$core$dist$core_browser_cjs
shadow.js.jsRequire @ /js/cljs-runtime/shadow.js.js:36
shadow$provide.module$node_modules$react_select$dist$react_select_browser_cjs @ /js/cljs-runtime/module$node_modules$react_select$dist$react_select_browser_cjs.js:3
shadow.js.jsRequire @ /js/cljs-runtime/shadow.js.js:34
shadow.js.require @ /js/cljs-runtime/shadow.js.js:55
eval @ /js/cljs-runtime/doublethedonation.integrations.records.js:9
goog.globalEval @ mp360.js?updated=20190805:827
env.evalLoad @ mp360.js?updated=20190805:2174
(anonymous) @ mp360.js?updated=20190805:2633
/js/cljs-runtime/shadow.js.js:36 shadow-cljs - failed to load module$node_modules$react_select$dist$react_select_browser_cjs

joshkh19:09:00

(and thanks for the response!)

thheller19:09:19

react-select loads fine for me, so most likely a version conflict with some other lib you have

kanwei19:09:16

it seems to be failing on emotion/core but nothing else uses it

kanwei19:09:47

i'll mess around

thheller19:09:58

where is the rest of the error? there should be more?

thheller19:09:39

ie. actual exceptions? not the yellow parts in the console log?

kanwei19:09:11

ok it had to do with the fact that inferno-compat doesn't have React.createContext

kanwei19:09:03

but now when i require ["react-select" :refer [Select]]

kanwei19:09:16

and do

[:> Select {:options [{:value "Chocolate" :label "Chocolateee"}]}]

kanwei19:09:40

it's creating

<undefined options="[object Object]"></undefined>

thheller19:09:46

well you are on your own if you use custom setups like inferno and stuff

thheller19:09:34

don't know anything about react-select. you might need to pass more options?

thheller19:09:03

and dunno if reagent converts converts nested props?

thheller19:09:08

might need clj->js?

kanwei20:09:13

had to use ["react-select" :default Select]

kanwei20:09:43

javascript is mad confusing

thheller20:09:43

yeah and it'll get worse before it gets better šŸ˜ž