Fork me on GitHub
#shadow-cljs
<
2020-07-17
>
adam00:07:29

How can I run shadow watch app on my local IP instead of localhost? I want to test my app on mobile

thheller06:07:18

@hoertlehner people have reported that this happens when the output files are on the classpath? did you upgrade the JDK version? that would explain the nashorn warning?

awb9907:07:18

I did not update jvm. Nashorn warning now comes when shadow checks npm dependencies.

awb9907:07:46

Output goes to target/we app/public.

awb9912:07:01

@thheller Might this constant recompile issue happen also due to the bundle being in a resource path?

thheller14:07:53

I don't have a clue whats causing this. otherwise I'd fix it.

thheller14:07:07

it might be your editor

thheller14:07:18

or some other watcher touching files

thheller14:07:48

can't do much without a reproducible example

thheller06:07:33

@somedude314 it should be available on your local IP automatically?

adam13:07:34

Ah you are right, thanks. I didn’t think that was the case because the console says “localhost”

Drew Verlee14:07:12

When i run shadow-cljs watch app s i get a warning about shadow cljs devtools not being able to locate refactor nrepl:

[2020-07-17 09:22:55.580 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym refactor-nrepl.middleware/wrap-refactor}
FileNotFoundException Could not locate refactor_nrepl/middleware__init.class, refactor_nrepl/middleware.clj or refactor_nrepl/middleware.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
	clojure.lang.RT.load (RT.java:462)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
	clojure.core/load-one (core.clj:5903)
	clojure.core/load-lib/fn--6780 (core.clj:5948)
	clojure.core/load-lib (core.clj:5947)
	clojure.core/load-lib (core.clj:5928)
	clojure.core/apply (core.clj:667)
	clojure.core/load-libs (core.clj:5985)
I'm not sure what to do. Should i be including refactor nrepl middlware? I can make a minimal project if that would help debug this. Many thanks on any hints.

thheller14:07:04

you have configured that middleware somewhere. shadow-cljs does not use it. well maybe cider-nrepl or whatever configures it? I don't really know.

thheller14:07:02

might be in your global config again?

thheller14:07:25

all the default nrepl locations apply, not sure what they are exactly. I think .nrepl.edn in your project and somewhere else

Drew Verlee14:07:57

➜ Cabotage git:(master) ✗ cat ~/.nrepl/nrepl.edn {:middleware [refactor-nrepl.middleware/wrap-refactor]} Many thanks. This is likely it. i had no idea this existed. I must say, its sometimes overwhelming all the places dependencies can be set.

thheller14:07:24

hmm yeah I couldn't decide whether I should adopt nrepl defaults or not

Karol Wójcik14:07:29

Is it possible for shadow-cljs to generate full externs file like that tool does? http://jmmk.github.io/javascript-externs-generator/

thheller14:07:06

no. why would it? that tool should never be used by anyone.

Karol Wójcik14:07:42

I would like to generate externs for react-jss to provide cljsjs.react-jss package as a backward compatibility for people who will not use the new :target :bundle option. Seems that the generator I've linked is unable to produce externs for https://github.com/FieryCod/cljs-react-jss/blob/master/resources/cljsjs/react-jss.js. Thought that maybe shadow-cljs is able to do it.

thheller14:07:18

so you are using react-jss in your library?

thheller14:07:47

ok then add extern inference hints in YOUR library

thheller14:07:01

then react-jss doesn't need any externs at all

thheller14:07:32

unless users of your library also use react-jss directly and don't use your stuff your library already uses.

😄 3
Karol Wójcik15:07:53

I would rather allow the users to consume react-jss directly

thheller15:07:11

you can also write the more "modern" CLJSJS style. you are writing the bad old style.

Karol Wójcik15:07:37

Ok guide me master.

Karol Wójcik15:07:44

What the "modern" means?

thheller15:07:45

no clue how it works exactly but you can configure :foreign-libs to "provide" react-jss

thheller15:07:04

so (:require ["react-jss" :as x]) works regardless of using CLJSJS or shadow-cljs or bundle

thheller16:07:40

so just use the react-jss require and alias instead of the global js/ alias

thheller16:07:27

like reagent https://github.com/reagent-project/reagent/blob/master/src/reagent/dom.cljs#L2 it doesn't use any js/ globals anymore because the compiler does that automatically when using cljsjs

Karol Wójcik16:07:58

Ok got it! You're right I can simply use ["react-jss" :as react-jss] and compatibility will be preserved.

Karol Wójcik16:07:57

It seems that I do not have to provide cljsjs.react-jss namespace as well. Am I right?

thheller19:07:04

yes, thats not required

Karol Wójcik22:07:49

Thank you @thheller! You are awesome!

Drew Verlee20:07:44

I assume this warning means ill need to supply a type hint:

17 |                   (let [x @loadable]
  18 |                     (when-some [modules (.-modules loadable)]
-----------------------------------------------^--------------------------------
Cannot infer target type in expression (. loadable -modules)
Will there be more then that?

thheller20:07:05

I don't understand the question?

Drew Verlee20:07:10

Shadow is giving me a warning that it cannot infer the target type. My assumption is that i have to tell it the type, is that correct?

thheller20:07:06

yes, that is an externs inference warning

thheller20:07:30

if you don't wan't them you can turn the warnings off

thheller20:07:36

I just turned them on by default recently

👏 3
thheller20:07:48

:compiler-options {:infer-externs true} turns them off

Drew Verlee20:07:06

makes sense. ill think about if i want i need to do more later

thheller20:07:36

it might compile fine without hints

Drew Verlee20:07:56

https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options It says it should be true by default or i'm i reading that wrong

thheller20:07:53

didn't update that

thheller20:07:09

its now :infer-externs :auto by default

Drew Verlee20:07:14

awesome. as always thanks for the help @thheller

Felipe Marques23:07:32

I'm trying to write a build-hook that adds some preloads. The build-hook runs on the :configure stage and adds the preload like this:

(update-in build-state [:devtools :preloads] conj 'my.preload.namespace)
Is it possible to do this?