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?
I’m getting ajax.edn is not available
even though I have cljs-ajax/cljs-ajax in deps.edn
How to fix this error?
all my imports in deps.edn aren’t working
are you using :deps true
option?
https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn
can you share your shadow-cljs.edn
and deps.edn
?
when I use the deps true option I get this error
http://java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class or shadow/cljs/devtools/cli.clj on classpath.
when loading the repl
in particular > You must add the thheller/shadow-cljs artifact to your deps.edn manually.
I added the artifact, but now I get a different error:
Caused by: java.lang.RuntimeException: Unable to resolve var: comp/source-map-data-gen-col in this context
Here’s my shadow-cljs.edn
{: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]}}}}
Here’s my deps.edn
{: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”]}
try with cljs version "1.10.597"
which is the one shadow uses
that gives the following:
============================================================================= 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
https://github.com/thheller/shadow-cljs/issues/460#issuecomment-472047147
https://clojars.org/thheller/shadow-cljs
@ps Specifying org.clojure/clojurescript 1.10.773
might help
oh sorry. i recommended that cljs version as i found it in shadow's deps.edn
shadow-cljs version specifies clojurescript version so I think you need to keep it the same
it works now
Oh I overlooked dpsutton's recommendation 🙇
1.10.773 made it work
In addition, you can omit :dependencies
entry as the warning said.
I’m getting an error when importing and using AsyncStorage
“error is ” #object[TypeError TypeError: undefined is not an object (evaluating ‘shadow.js.shim.module$$react_native_async_storage$async_storage.AsyncStorage.setItem’)]
using
(reg-event-fx
:_id-persist
(fn [coeffects [_ id]]
(go
(try
(<p! (. AsyncStorage setItem "_id" id))
(catch js/Error e (prn "error is " e))))
{}
))
importing
["@react-native-async-storage/async-storage" :refer (AsyncStorage)]
why is AsyncStorage undefined?
@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
import { AsyncStorage } from “react-native”;
from https://pusher.com/tutorials/persisting-data-react-native
which translates to what i have
actually import AsyncStorage from ‘@react-native-async-storage/async-storage’;
thanks
@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?
Also, is there a way to tell shadow to safely bail, in a build hook? Or should I just throw an exception?
to my first question: I want to watch all files against a specific path, and have them considered by the analyzer
@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.
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