Fork me on GitHub
#shadow-cljs
<
2021-01-07
>
isak00:01:26

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.eth02:01:36

I’m getting ajax.edn is not available

zendevil.eth02:01:48

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

zendevil.eth02:01:41

How to fix this error?

zendevil.eth02:01:04

all my imports in deps.edn aren’t working

saitouena02:01:50

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

zendevil.eth02:01:30

when I use the deps true option I get this error

zendevil.eth02:01:49

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

zendevil.eth02:01:41

when loading the repl

dpsutton02:01:32

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

👀 3
zendevil.eth02:01:40

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

zendevil.eth02:01:41

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

zendevil.eth02:01:59

Here’s my shadow-cljs.edn

zendevil.eth02:01:01

{: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.eth02:01:55

Here’s my deps.edn

zendevil.eth02:01:56

{: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”]}

dpsutton02:01:28

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

zendevil.eth02:01:16

that gives the following:

zendevil.eth02:01:17

============================================================================= 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

saitouena03:01:06

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

dpsutton03:01:28

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

3
saitouena03:01:28

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

saitouena03:01:52

Oh I overlooked dpsutton's recommendation 🙇

zendevil.eth03:01:39

1.10.773 made it work

🎉 3
saitouena03:01:52

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

3
zendevil.eth11:01:40

I’m getting an error when importing and using AsyncStorage

zendevil.eth11:01:50

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

zendevil.eth11:01:34

using

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

zendevil.eth11:01:48

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

zendevil.eth11:01:15

why is AsyncStorage undefined?

thheller11:01:29

@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.eth12:01:51

import { AsyncStorage } from “react-native”;

zendevil.eth12:01:23

which translates to what i have

zendevil.eth12:01:17

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

Alexis Vincent17:01:45

@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 Vincent17:01:28

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

Alexis Vincent17:01:43

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

thheller19:01:14

@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 Vincent19:01:08

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