Fork me on GitHub
#clojurescript
<
2022-12-06
>
quan xing13:12:04

this is my first clojurescirpt with shadow-cljs :

;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :deps false

 :dependencies
 []

 :dev-http {4000  "target/"}
 :builds
 {:app {:output-dir "target/"
        :asset-path "."
        :target :browser
        :modules {:main {:init-fn }}
        :devtools {:after-load }}}}
app.cljs:
(def value-a 1)
(defonce value-b 2)
(defn reload! []
  (println "Code upddd.")
  (println "Trying values:" value-a value-b)
  (js/console.log "code reload"))

(defn ^:export main! []
  (println "App loaded!")
  (js/console.log "hello"))

(tap> "hffffI")
run: npx shadow-cljs watch :app in Chorme show error: No such namespace:js Why? In emacs I use M-x cider-connect also show error so I use npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :app It doesn't work

p-himik13:12:40

I have no clue about that particular window or Cider but that error by itself makes me think that you're trying to run CLJS code in a CLJ REPL.

Apple13:12:38

shadow.user is a CLJ repl prompt

Apple13:12:04

(shadow/repl :app)
missing this

quan xing13:12:27

I change vscode now:

p-himik14:12:24

The error is quite clear - just follow that link.

Apple14:12:48

emacs works. you just need to switch to cljs repl by (shadow/repl :app) open a browser and it'll go away

dharrigan16:12:18

Would this be the right channel to ask about styling (if one is just getting to grips with clojurescript?)

p-himik16:12:39

By styling, you mean CSS? Unless it's CSS-in-CLJS, I'd say no. We have #C06DTLT5X though.

dharrigan16:12:17

Ah, I'll jump to there, thank you! I knew I would be directed somewhere more appropriate 🙂

p-himik16:12:22

We have a lot of channels. :) Most of the time, I don't even use the channel search function - I just start typing # followed by something relevant, and there it is.

💯 1
Lucio Assis22:12:27

Does cljs have a port of resources in some fashion? As in ? I wanted my library to load the full contents of a text file by name. It’s currently a clj lib, so it just includes the text file as a resource in the jar and loads it up when needed. Wondering if there’s a way to do something similar in cljs.

phill23:12:57

You can define a macro (which runs in Clojure and can access such resources) that evaluates to a string literal that you can use in your cljs.

colinkahn23:12:30

If you're using shadow-cljs you can require [shadow.resource :as rc] and do (rc/inline "...") with the file path.

😃 1
💡 1
Lucio Assis01:12:41

I am! Thanks so much both of you.