Fork me on GitHub
#shadow-cljs
<
2021-01-20
>
zendevil.eth05:01:02

I’m getting an error when importing and using a module

zendevil.eth05:01:19

Here’s how it’s imported:

zendevil.eth05:01:19

[“@react-native-community/cameraroll” :default CameraRoll]

zendevil.eth05:01:28

Here’s how it’s used:

zendevil.eth05:01:41

(. CameraRoll save (.-uri (<p! (. @!camera recordAsync))))

zendevil.eth05:01:46

Here’s the error:

zendevil.eth05:01:20

undefined is not an object (evaluating ‘shadow.js.shim.module$ $react_native-community$cameraroll.default.save’)

zendevil.eth05:01:26

How to fix this error?

thheller10:01:54

@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)]

Karol Wójcik11:01:56

cache-blockers

pinkfrog13:01:49

There is like 5 seconds delay between i save the cljs file and shadow recompiling it.

pinkfrog13:01:54

How to make it shorter?

thheller13:01:22

do you use macos big sur?

thheller14:01:09

yeah I heard reports that its a lot slower there since they removed some stuff basically all CLJ(S) projects used

thheller14:01:18

ie. they broke hawk

valsen15:01:38

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?

valsen15:01:34

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"]}}}

thheller17:01:31

looks fine. what is the problem?

valsen19:01:40

@thheller My namespaces in src/cljs are not being recognized, and neither are the required dependencies, as you can see in this screenshot

thheller19:01:25

well thats a Cursive issue. not anything to do with shadow-cljs

valsen19:01:38

ah ok, i see

thheller19:01:04

Cursive doesn't support shadow-cljs.edn so it doesnt "see" the source-paths and dependencies

thheller19:01:25

only option really is to put everything into deps.edn

valsen19:01:02

ok, will do that then. Thanks for the explanation!:)

valsen20:01:46

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:)

Jp Soares17:01:28

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.

thheller18:01:21

no, that is a shadow-cljs feature not part of regular cljs

Jp Soares18:01:07

hum.. ok, but I also tried the :warning-handlers and it also didn't work.

thheller18:01:32

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

Jp Soares18:01:45

Thanks.. maybe the #clojurescript would be a better channel for this question?

fsd19:01:03

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!

thheller19:01:52

I guess you are looking at the file without an http server? just opening the index.html?

fsd20:01:21

Correct, index.html

fsd20:01:49

after linking up all the file, everything loads main.js css file except background-image: url (“”)

thheller20:01:49

well by using a path like /icons/square.png it'll look at an absolute path for your file

thheller20:01:15

so if you open /home/user/project/foo/index.html it'll look for /icons/square.png

thheller20:01:28

which is not where you have the files very likely 😛

thheller20:01:42

you can either use icons/square.png so the path is relative to the current file

thheller20:01:54

or use an http server which you'll likely use/need anyways

fsd20:01:06

I tried using this on both opening index.html and local server and did not work

thheller20:01:46

well if you show me your config and setup I can tell you whats wrong

thheller20:01:54

without that I'm guessing which helps no one