I’m getting an error when importing and using a module
Here’s how it’s imported:
[“@react-native-community/cameraroll” :default CameraRoll]
Here’s how it’s used:
(. CameraRoll save (.-uri (<p! (. @!camera recordAsync))))
Here’s the error:
undefined is not an object (evaluating ‘shadow.js.shim.module$ $react_native-community$cameraroll.default.save’)
How to fix this error?
@ps same problem as always. it might not be :default
it might be :as
or :refer
. [“@react-native-community/cameraroll” :as CameraRoll]
or [“@react-native-community/cameraroll” :refer (CameraRoll)]
Is it possible to modify: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/api.clj#L114?
modify what? https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache ?
cache-blockers
Ok got it!
Thank you @thheller
There is like 5 seconds delay between i save the cljs file and shadow recompiling it.
How to make it shorter?
do you use macos big sur?
yes
yeah I heard reports that its a lot slower there since they removed some stuff basically all CLJ(S) projects used
ie. they broke hawk
Hi everyone, I’m setting up a fullstack project with deps.edn
and shadow-cljs.edn
, and I have a “clj” and a “cljs” folder in src. I want shadow-cljs.edn
to manage the cljs dependencies, but they are not being recognized at all. If I set :deps true
I can successfully manage them from deps.edn
instead, but I would prefer not having to do that. Any ideas what I might be doing wrong?
Oh and here’s shadow-cljs.edn
:
{:source-paths ["src/cljs"]
:dependencies
[[re-frame "1.1.2"]
[reagent "0.9.1"]]
:builds
{:app {:target :browser
:output-dir "resources/public/js"
:asset-path "/js"
:modules {:main {:init-fn wallet.core/init}}
:devtools {:http-root "resources/public"
:http-port 4200}}}
:nrepl {:port 9000}}
and deps.edn
:
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
metosin/reitit {:mvn/version "0.5.10"}
http-kit/http-kit {:mvn/version "2.5.0"}}
:paths ["src/clj" "resources"]
:aliases {:run {:main-opts ["-m" "wallet.core"]}}}
looks fine. what is the problem?
Is there a way to use the compiler option {:warnings-as-errors true}
with cljs.js/eval-str
?
It looks like the available options of [cjs.js/eval-str](https://cljs.github.io/api/cljs.js/eval-str) are limited.
(defn evaluate [s callback]
(cljs.js/eval-str
compile-eval-state
s
nil
{:eval cljs.js/js-eval
:load (partial shadow.bootstrap/load (analyzer/empty-state))
:warnings-as-errors true
:context :expr}
(fn [result] (do (js/console.log result)
(callback result)))))
I also tried to pass compiler-options as an argument of analyzer/empty-state
but I had no success.no, that is a shadow-cljs feature not part of regular cljs
hum.. ok, but I also tried the :warning-handlers
and it also didn't work.
sorry can't help with self-host questions much. can't expect shadow-cljs features to work there since that is using all the regular cljs compiler stuff without any of the shadow-cljs additions/tweaks
Thanks.. maybe the #clojurescript would be a better channel for this question?
probably
Hi There,
I have shadow.cljs application, when I run yarn build
, it gives generates build file main.js. After linking the css and main.js to index.html it gives error on some of the assets file for ex png images. The css file background-image: url("/icons/square.png")
these gives 404.
Any help would be appreciated!
@thheller My namespaces in src/cljs are not being recognized, and neither are the required dependencies, as you can see in this screenshot
I guess you are looking at the file without an http server? just opening the index.html?
well thats a Cursive issue. not anything to do with shadow-cljs
ah ok, i see
Cursive doesn't support shadow-cljs.edn so it doesnt "see" the source-paths and dependencies
only option really is to put everything into deps.edn
ok, will do that then. Thanks for the explanation!:)
Correct, index.html
after linking up all the file, everything loads main.js css file except background-image: url (“”)
If anyone else looks at this thread and notices that I forgot to add :as reagent
and :as re-frame
in the requirements, that was just when I quickly prepared the code to demonstrate. The problem persists with correct requirements and is due to Cursive, like thheller explained:)
well by using a path like /icons/square.png
it'll look at an absolute path for your file
so if you open /home/user/project/foo/index.html
it'll look for /icons/square.png
which is not where you have the files very likely 😛
you can either use icons/square.png
so the path is relative to the current file
or use an http server which you'll likely use/need anyways
I tried using this on both opening index.html and local server and did not work
well if you show me your config and setup I can tell you whats wrong
without that I'm guessing which helps no one