shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
isak 2021-01-07T00:23:26.354800Z

Sometimes I get compilation issues while switching branches, I'm guessing because git may create a reference to a file before it creates the file that is being referred to. Not a huge deal since a page-reload makes it go away, but when watching, how about checking if git is doing an operation before doing the compile? I think this can be done by checking the existence of .git/index.lock. Not sure if it is worth it, just putting it out there. Actually for the implementation, since shadow-cljs is already watching for file system changes to .cljs files, how about .git/index.lock as well?

zendevil 2021-01-07T02:09:36.355400Z

I’m getting ajax.edn is not available

zendevil 2021-01-07T02:09:48.355800Z

even though I have cljs-ajax/cljs-ajax in deps.edn

zendevil 2021-01-07T02:10:41.356Z

How to fix this error?

zendevil 2021-01-07T02:16:04.356300Z

all my imports in deps.edn aren’t working

saitouena 2021-01-07T02:21:11.356900Z

are you using :deps true option? https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn

saitouena 2021-01-07T02:21:50.357400Z

can you share your shadow-cljs.edn and deps.edn ?

zendevil 2021-01-07T02:23:30.357900Z

when I use the deps true option I get this error

zendevil 2021-01-07T02:23:49.358100Z

http://java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class or shadow/cljs/devtools/cli.clj on classpath.

zendevil 2021-01-07T02:24:41.358300Z

when loading the repl

dpsutton 2021-01-07T02:26:32.358900Z

in particular > You must add the thheller/shadow-cljs artifact to your deps.edn manually.

👀 1
zendevil 2021-01-07T02:29:40.359600Z

I added the artifact, but now I get a different error:

zendevil 2021-01-07T02:29:41.359800Z

Caused by: java.lang.RuntimeException: Unable to resolve var: comp/source-map-data-gen-col in this context

zendevil 2021-01-07T02:32:59.360200Z

Here’s my shadow-cljs.edn

zendevil 2021-01-07T02:33:01.360400Z

{:deps true :source-paths [“src”] :dependencies [[reagent “0.10.0"] [re-frame “0.12.0”] [re-frame-steroid “0.1.1"] [rn-shadow-steroid “0.2.1”] [re-frisk-remote “1.3.3"]] :builds {:dev {:target :react-native :init-fn humboi.core/init :output-dir “app” :compiler-options {:closure-defines {“re_frame.trace.trace_enabled_QMARK_” true}} :devtools {:after-load steroid.rn.core/reload :build-notify steroid.rn.core/build-notify :preloads [re-frisk-remote.preload]}}}}

zendevil 2021-01-07T02:33:55.360600Z

Here’s my deps.edn

zendevil 2021-01-07T02:33:56.360800Z

{:deps {org.clojure/clojure {:mvn/version “1.10.0”} org.clojure/clojurescript {:mvn/version “1.10.339"} reagent {:mvn/version “0.10.0”} re-frame {:mvn/version “0.12.0"} re-frame-steroid {:mvn/version “0.1.1”} rn-shadow-steroid {:mvn/version “0.2.1"} cljs-ajax/cljs-ajax {:mvn/version “0.8.1”} day8.re-frame/http-fx {:mvn/version “0.2.2"} thheller/shadow-cljs {:mvn/version “2.11.11”}} :paths [“src”]}

dpsutton 2021-01-07T02:35:28.361300Z

try with cljs version "1.10.597" which is the one shadow uses

zendevil 2021-01-07T02:44:16.361700Z

that gives the following:

zendevil 2021-01-07T02:44:17.361900Z

============================================================================= WARNING: The configured :dependencies in shadow-cljs.edn were ignored! When using :deps they must be configured in deps.edn ============================================================================== ============================================================================== WARNING: The configured :source-paths in shadow-cljs.edn were ignored! When using :deps they must be configured in deps.edn ============================================================================== NPM dependency “react” has installed version “16.13.1" “16.13.0” was required by jar:file:/private/var/root/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs [2021-01-07 08:13:51.446 - WARNING] :shadow.cljs.devtools.server/nrepl-ex Note: The following stack trace applies to the reader or compiler, your code was not executed. CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source “cider/piggieback.clj”, :symbol if-ns} clojure.lang.Compiler.macroexpand1 (Compiler.java:7018) clojure.lang.Compiler.macroexpand (Compiler.java:7074) clojure.lang.Compiler.eval (Compiler.java:7160) clojure.lang.Compiler.load (Compiler.java:7635) clojure.lang.RT.loadResourceScript (RT.java:381) clojure.lang.RT.loadResourceScript (RT.java:372) clojure.lang.RT.load (RT.java:463) clojure.lang.RT.load (RT.java:428) clojure.core/load/fn--6824 (core.clj:6126) clojure.core/load (core.clj:6125) clojure.core/load (core.clj:6109) clojure.core/load-one (core.clj:5908) Caused by: NoSuchFieldError ES3 cljs.closure__init.load (:133) cljs.closure__init.<clinit> (:-1) java.lang.Class.forName0 (Class.java:-2) java.lang.Class.forName (Class.java:348) clojure.lang.RT.classForName (RT.java:2207) clojure.lang.RT.classForName (RT.java:2216) clojure.lang.RT.loadClassForName (RT.java:2235) clojure.lang.RT.load (RT.java:453) clojure.lang.RT.load (RT.java:428) clojure.core/load/fn--6824 (core.clj:6126) clojure.core/load (core.clj:6125) clojure.core/load (core.clj:6109) shadow-cljs - server version: 2.11.11 running at http://localhost:9630

saitouena 2021-01-07T03:11:58.362100Z

https://github.com/thheller/shadow-cljs/issues/460

saitouena 2021-01-07T03:15:06.363600Z

https://clojars.org/thheller/shadow-cljs @ps Specifying org.clojure/clojurescript 1.10.773 might help

dpsutton 2021-01-07T03:16:28.364100Z

oh sorry. i recommended that cljs version as i found it in shadow's deps.edn

1
saitouena 2021-01-07T03:17:28.364800Z

shadow-cljs version specifies clojurescript version so I think you need to keep it the same

zendevil 2021-01-07T03:18:12.365100Z

it works now

saitouena 2021-01-07T03:18:52.365700Z

Oh I overlooked dpsutton's recommendation 🙇

zendevil 2021-01-07T03:19:39.366Z

1.10.773 made it work

🎉 1
saitouena 2021-01-07T03:20:52.366900Z

In addition, you can omit :dependencies entry as the warning said.

✅ 1
zendevil 2021-01-07T11:15:40.367600Z

I’m getting an error when importing and using AsyncStorage

zendevil 2021-01-07T11:15:50.367800Z

“error is ” #object[TypeError TypeError: undefined is not an object (evaluating ‘shadow.js.shim.module$$react_native_async_storage$async_storage.AsyncStorage.setItem’)]

zendevil 2021-01-07T11:16:34.368300Z

using

(reg-event-fx
 :_id-persist
 (fn [coeffects [_ id]]
   
   (go
     (try
       (&lt;p! (. AsyncStorage setItem "_id" id))
       (catch js/Error e (prn "error is " e))))
   {}
   ))

zendevil 2021-01-07T11:16:35.368500Z

importing

zendevil 2021-01-07T11:16:48.368800Z

["@react-native-async-storage/async-storage" :refer (AsyncStorage)]

zendevil 2021-01-07T11:17:15.369500Z

why is AsyncStorage undefined?

thheller 2021-01-07T11:26:29.369900Z

@ps it might be :as AsyncStorage not :refer, or even :default AsyncStorage. see the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages

zendevil 2021-01-07T12:01:51.370200Z

import { AsyncStorage } from “react-native”;

zendevil 2021-01-07T12:02:14.370500Z

from https://pusher.com/tutorials/persisting-data-react-native

zendevil 2021-01-07T12:02:23.370800Z

which translates to what i have

zendevil 2021-01-07T12:04:17.371100Z

actually import AsyncStorage from ‘@react-native-async-storage/async-storage’;

zendevil 2021-01-07T12:19:48.371300Z

thanks

Alexis Vincent 2021-01-07T17:28:45.374800Z

@thheller I’m running a watch process, running a build hook which finds functions with specific metadata and outputs a file because of it. When I add a new cljs file, I want that to be included in the watch/analyse/compile process. Is there a way to tell shadow to start watching this new file as well? If not, is there a way extend shadow user side to do this?

Alexis Vincent 2021-01-07T17:32:28.375800Z

Also, is there a way to tell shadow to safely bail, in a build hook? Or should I just throw an exception?

Alexis Vincent 2021-01-07T17:49:43.377500Z

to my first question: I want to watch all files against a specific path, and have them considered by the analyzer

thheller 2021-01-07T19:34:14.379200Z

@mail024 none of the default :target implementations support this. what exactly do those files do? usually only files that are actually required by something will be included.

Alexis Vincent 2021-01-07T19:38:08.382500Z

It’s really only in development that I want this. I’m doing something similar to what you do here https://github.com/thheller/next-cljs/blob/master/src/main/shadow/next_js.clj#L12. I got around this by watching the files myself and generating a “dev.cljs” file that contains requires for the files. This is good enough. But knowing how to include all files rather then just those reachable via entries would be useful for simplification of the implementation. Not vital given the workaround