Fork me on GitHub
#shadow-cljs
<
2019-12-13
>
Aleed00:12:52

can I only reference javascript packages in cljs? if so, how woould I go about referencing a js package in a macro?

Aleed00:12:20

ah i guess i'd wanna make sure it's only read and not evaluated until it reaches cljs

aisamu02:12:38

Macros are pure CLJ. You can't directly use the JS code on the macro, but you can spit the CLJS code that will use it. (e.g. if your macro is spitting some code as in (react/createElement foo) , the CLJS file that uses it must require react)

👍 4
wilkerlucio16:12:00

hello, I'm trying to port some old project from figwheel to shadow, but for some reason I'm getting this when I try to compile:

Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
	at com.google.javascript.rhino.IR.name(IR.java:381)

wilkerlucio16:12:18

I check closure version, seems correct (coming from Shadow)

wilkerlucio16:12:05

full error stack:

wilkerlucio16:12:08

Exception in thread "main" Syntax error compiling at (shadow/cljs/devtools/api.clj:1:1).
	at clojure.lang.Compiler.load(Compiler.java:7647)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:463)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:1523)
	at shadow.cljs.devtools.cli$eval1826$loading__6706__auto____1827.invoke(cli.clj:1)
	at shadow.cljs.devtools.cli$eval1826.invokeStatic(cli.clj:1)
	at shadow.cljs.devtools.cli$eval1826.invoke(cli.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7165)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:463)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at user$eval1809$fn__1813.invoke(form-init1501309315939750065.clj:1)
	at user$eval1809.invokeStatic(form-init1501309315939750065.clj:1)
	at user$eval1809.invoke(form-init1501309315939750065.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	at clojure.lang.Compiler.loadFile(Compiler.java:7573)
	at clojure.main$load_script.invokeStatic(main.clj:452)
	at clojure.main$init_opt.invokeStatic(main.clj:454)
	at clojure.main$init_opt.invoke(main.clj:454)
	at clojure.main$initialize.invokeStatic(main.clj:485)
	at clojure.main$null_opt.invokeStatic(main.clj:519)
	at clojure.main$null_opt.invoke(main.clj:516)
	at clojure.main$main.invokeStatic(main.clj:598)
	at clojure.main$main.doInvoke(main.clj:561)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.main.main(main.java:37)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
	at com.google.javascript.rhino.IR.name(IR.java:381)
	at com.google.javascript.jscomp.VarCheck.<clinit>(VarCheck.java:94)
	at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:243)
	at cljs.closure__init.load(Unknown Source)
	at cljs.closure__init.<clinit>(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at clojure.lang.RT.classForName(RT.java:2207)
	at clojure.lang.RT.classForName(RT.java:2216)
	at clojure.lang.RT.loadClassForName(RT.java:2235)
	at clojure.lang.RT.load(RT.java:453)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:2088)
	at cljs.repl$loading__5569__auto____6321.invoke(repl.cljc:9)
	at cljs.repl__init.load(Unknown Source)
	at cljs.repl__init.<clinit>(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at clojure.lang.RT.classForName(RT.java:2207)
	at clojure.lang.RT.classForName(RT.java:2216)
	at clojure.lang.RT.loadClassForName(RT.java:2235)
	at clojure.lang.RT.load(RT.java:453)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:3894)
	at shadow.cljs.devtools.api$eval2856$loading__6706__auto____2857.invoke(api.clj:1)
	at shadow.cljs.devtools.api$eval2856.invokeStatic(api.clj:1)
	at shadow.cljs.devtools.api$eval2856.invoke(api.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7165)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	... 68 more

wilkerlucio16:12:17

nevermind, was some deps problem in the end

thheller16:12:50

yeah thats a bad guava version I think

Wilson Velez19:12:37

Hi, I’m changing an old project from fighweel to shadow, it used cljsjs/hightcharts

Wilson Velez19:12:06

what should I use now highcharts npm or react-hightcharts npm?

hlolli19:12:11

@wvelezva if you used cljsjs/hightcharts, then look at their extern file https://github.com/cljsjs/packages/blob/master/highcharts/resources/cljsjs/highcharts/common/highcharts.ext.js and it looks to me that you were relying on hightcharts and not react-hightcharts.

mdhaney19:12:02

@thheller I was skimming this channel the other day, and someone mentioned a web socket issue with RN. Could you point me to the details of the issue? I’ve had some problems with websocket disconnects in development which I just attributed to flakey environment (I.e. going through ngrok), but I want to make sure it’s not something more serious.

Wilson Velez19:12:22

sorry, wrong question, now that I’m using shadow, I would like to use the highcharts js more directly, avoiding the cljsjs

thheller19:12:34

basically the websocket stays connected in android when you do an app reload

mdhaney19:12:30

Ah, ok. That’s not my issue. And it sounds like it would just be a dev issue anyway.

thheller19:12:07

yes, dev only. basically shadow-cljs just thinks that the REPL is still connected when it is not

hlolli19:12:35

is there a good trick to have shadow-cljs run babel after compilation, I want to use https://emotion.sh/docs/@emotion/babel-preset-css-prop to transform my js.

hlolli19:12:38

it's well documented babel + jsx and then import that. But I wonder with transformations on cljs sources (after compilation ofc, but before minification I'd assume).

thheller19:12:03

thats not supported

thheller19:12:26

you could in theory do it in a :compile-finish hook but there is nothing built-in to do that

thheller19:12:40

also will get quite messy dealing with source maps and stuff

hlolli19:12:55

ok np, I'll give compile-finish hook a try. Thanks

thheller19:12:57

check :build-sources in the compile state. those are the resource-ids for all sources that were compiled. (get-in build-state [:output resource-id]) will get you the compile output :js is the generated JS for example

hlolli19:12:36

ah yes, I remember how huge data is being passed, good to know, otherwise I'd get lost 🙂

thheller19:12:58

try (tap> build-state) and look at it in the Inspect UI

thheller19:12:09

it has no problem with huge data 😉

lilactown20:12:07

@hlolli you’re going to struggle to use that because CLJS doesn’t emit JSX

lilactown20:12:54

instead of transforming your JS, you should probably figure out a way to transform your CLJS code to use emotion

hlolli20:12:50

yes, it could be this wont work because of reagent. I think babel can be called on any js file, ancient or new.

hlolli20:12:06

I'm using emotion at a company I'm freelancing for in jsx. And I'd do anything do get it working in cljs with css prop. Lifesaver.

lilactown20:12:53

the babel-plugin works when it transforms JSX to JS code, though

lilactown20:12:08

so you can call it on any JS file, of course. it just won’t do anything unless you’re using JSX

hlolli20:12:08

it depends on the transformer?

lilactown20:12:33

I don’t understand your question

hlolli20:12:58

babel is a tool that can be used to transform any kind of js tranformation

hlolli20:12:38

ah I see thanks for that point

lilactown20:12:09

it takes JSX code <div css={color: green`} />` and hooks into the JSX parser to transform the css prop

hlolli20:12:23

so you think it would make sense to rewrite this transformation in shadow? Or patch reagent?

lilactown20:12:26

CLJS does not ever emit JSX, so you will never get any benefit from using that babel transform on your code

hlolli20:12:12

I'm surprised, since babel can be used for polyfills, typescript and ecmascript proposals, and transform es5 to es6 etc.

hlolli20:12:50

but in this case with that preset, it needs jsx true

lilactown20:12:37

if you’re using reagent, I’m not sure what you should do. you could use a function or macro to parse a :css prop in a map and do the transformation

hlolli20:12:56

I need to research, I think there's more to it. Because I should be able to pass it to className prop instead of css. But that doesn't work either. And I added this recently to a ts project and all I had to do was to add this babel preset and it works.

lilactown20:12:33

you can use emotion without the css prop, yes

lilactown20:12:10

(def my-styles (emotion/css #js {:color "green"}))

(defn my-component []
  [:div {:class my-styles} "Hello"])

hlolli20:12:48

in reagent, this isn't working

hlolli20:12:22

I realized I forgot to try js/react directly. But I had tried reagent/createElement, which is the same as if it were in hiccup vector

lilactown20:12:39

? I have no idea what you’re talking about

lilactown20:12:55

let’s take this to #reagent and stop cluttering #shadow-cljs