This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-28
Channels
- # announcements (5)
- # babashka (7)
- # beginners (101)
- # biff (9)
- # calva (46)
- # cider (6)
- # clj-yaml (2)
- # cljsrn (13)
- # clojure (11)
- # clojure-europe (43)
- # clojure-nl (13)
- # clojure-norway (22)
- # clojurescript (20)
- # conjure (1)
- # cursive (7)
- # data-science (2)
- # datomic (26)
- # emacs (38)
- # graphql (27)
- # gratitude (5)
- # hoplon (8)
- # hugsql (22)
- # humbleui (2)
- # hyperfiddle (6)
- # introduce-yourself (8)
- # joyride (3)
- # lsp (79)
- # malli (6)
- # nbb (67)
- # portal (16)
- # rdf (27)
- # reagent (42)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (36)
- # test-check (17)
- # tools-deps (1)
- # xtdb (15)
Is it possible to import custom code from typescript files like this in shadow-cljs?
(def component (js/require "./typescript/component.tsx"))
No, you need to compile them to JavaScript first
Does shadow support bundling json files?
(ns my-project.my-ns
(:require ["./assets.json" :as assets]))
or
(def assets (js/require "./assets.json"))
Having trouble getting it working though. I'm putting the code in a cljc file wrapped in a conditional as I need to target nbb and shadow-cljs
#?(:org.babashka/nbb
(do
(ns crunchy.assets)
(def assets (js/require "./assets.json")))
:cljs
(do
(ns crunchy.assets
(:require
[shadow.resource :refer [inline]]))
(def assets (inline "./assets.json"))))
(defn asset
[rel-path]
(let [actual-path (aget assets rel-path)]
(when-not actual-path
(throw (js/Error. (str "Could not lookup asset " rel-path))))
actual-path))
Error:
[:app] Compiling ...
Closure compilation failed with 1 errors
--- crunchy/assets.cljc:8
Required namespace "shadow.resource" never defined.
(ns crunchy.assets
(:require
#?@(:nbb []
:cljs [[shadow.resource :refer [inline]]])))
(def assets
#?(:nbb
(js/require "./assets.json")
:cljs
(inline "./assets.json")))
but note that inline just gives the the JSON string, not the object. so you'd need to parse that first
hmm no idea. never seen that. must be something npm related. definitely nothing from shadow-cljs.
Having trouble getting it working though. I'm putting the code in a cljc file wrapped in a conditional as I need to target nbb and shadow-cljs
https://gist.github.com/Deraen/a699de28866c117566e7d0d3f9088440
Any idea if these infer-warnings on Reagent test suite are real problems, and if there is way to clear up the warnings?
All seem to be from deftype
declaration, not even about calling those methods. Maybe the problem is that these "private" methods are just extending Object and they aren't declared on any protocols?
which shadow-cljs/cljs version do you use? looks like warnings on an older version that should be fixed?
you can also just set (set! *warn-on-infer* false)
in the file to get rid of the warnings
I have a shadow-cljs.edn config that moves a folder using a build-hook as follows:
:prod {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:build-hooks
[(build/move-directory
"node_modules/@fortawesome/fontawesome-pro/webfonts"
"resources/public/webfonts")]
...}}}
and same for dev. When using shadow-cljs release prod
this build hook does not seem to move the files… Should it?same hook does work for dev
build via shadow-cljs compile dev
@erwinrooijakkers why is this a build hook in the first place? wouldn't a simple cp node_modules/@fortawesome/fontawesome-pro/webfonts resources/public/webfonts
solve the same problem in a much simpler way?
it would. the reason it didn’t work was because the function was called copy-directory
, not move. i do think it’s more logical to move this specific build step into a Makefile or so. thanks
I can't see the implementation of your hook, I guess you are doing some dev filtering? shadow-cljs will call it for release
the same way as dev
shadow-cljs compile dev
the build is called prod
? which is not a recommended build separation. dev/prod should be the same build
Is there any way to make shadow-cljs watch for file changes in a specific directory and have it call :after-load function? I tried this
:devtools {:watch-dir "public" :watch-path "/foo"}
But unfortunatly nothing happens.
I have a folder with javascript files, and I am using (js/require "...") to require it in my react native project. I would like a change in the folder to trigger my :after-load function so that the changes become visible without having to reload the app.@shakof91 shadow only watches files relevant to the build. JS files provided by metro it doesn't watch and there is no way to make it watch that. there is also sort of no way to make it reload those unless you still have react-native hot-reload still active? which will interfere with shadow-cljs hot-reload, so kinda a tricky topic
That is understandable. I will just activate "Fast refresh" when I am working in javascript world and disable it when I am in cljs world. This works, so not a blocker at all! 😄 Thank you for the quick answer!
is there a way to connect the browser repl to an existing build (for use with nREPL)? stupid console.log isn't playing well with my nREPL, seeing if shadow does better for me
I do not understand the question. yes, nrepl is supported. not a clue what you mean by console.log isn't playing with nrepl? the two are in no way related?