This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-02
Channels
- # announcements (11)
- # aws (3)
- # babashka (34)
- # beginners (20)
- # biff (2)
- # calva (3)
- # cherry (29)
- # cider (6)
- # cljs-dev (9)
- # clojure (124)
- # clojure-europe (12)
- # clojure-norway (5)
- # clojure-uk (2)
- # clojurescript (32)
- # conjure (11)
- # datalevin (1)
- # datomic (16)
- # deps-new (1)
- # etaoin (6)
- # holy-lambda (10)
- # honeysql (28)
- # hyperfiddle (21)
- # jackdaw (2)
- # jobs (2)
- # leiningen (15)
- # missionary (12)
- # off-topic (132)
- # other-languages (1)
- # pathom (13)
- # rdf (10)
- # re-frame (8)
- # reagent (5)
- # releases (1)
- # remote-jobs (4)
- # shadow-cljs (32)
- # tools-deps (6)
- # vim (15)
- # xtdb (24)
@thheller Thank you for reply. > the issue was gone too to be honest I read https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/fs_watch.clj & https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/util/FileWatcher.java, and I thought so too. My environment is below: • Java: openjdk 17.0.3 2022-04-19 LTS • shadow-cljs: 2.19.6 • Node.js: v16.16.0 • VSCode: 1.69.2 • Docker: 20.10.17, build 100c701 • Docker Desktop for Windows: 4.10.1 • Windows: 10(19044, 1826) You can use https://github.com/blackawa/isomorphic-clojure-webapp to reproduce an issue. I tried on 2 Windows machine, and trying on my Mac machine tonight.
well its a known issue that file watchers have trouble working in containers. not really specific to shadow-cljs at all. I don't know how devcontainers work exactly so I don't have any guesses
Does :target :browser
support js/require
?
Well OK, I thought maybe there was some machinery at the bundle level because I saw on some React/Reagent projects (def sym (js/require...)
but
I'm sure now that is the case for :target :react-native
for eg. https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L11
Thanks for the confirmation. 😉
And in this snippet (coming from React Inertia.js doc https://inertiajs.com/client-side-setup), it's managed by the bundler I guess.
createInertiaApp({
resolve: name => require(`./Pages/${name}`),
setup({ el, App, props }) {
render(<App {...props} />, el)
},
})
in that case js/require
would be supported, assuming the shadow-cljs is run through the webpack build as well
interesting...yes with using Shadow-CLJS :js-provider :external
option for example.
I'm thinking about using your Next-cljs hook trick https://github.com/thheller/next-cljs/blob/master/shadow-cljs.edn#L13 to generate pages to require it automatically like the above Inertia example.
no :external
would not work for this. the CLJS output doesn't go through webpack in that case
This in order to avoid to manage manually theses pages like I do for now https://github.com/prestancedesign/pingcrm-clojure/blob/main/src/cljs/pingcrm/app.cljs#L18-L34
> no :external
would not work for this
Ha ok. so what the solution? Continue to use :target :browser
and pass the generated JS bundled file through Webpack directly?
In few words, Inertia backend adapter add a data-page
attribute containing a stringify JSON obj. Eg:
<div id="app" data-page="{component: \"homepage\", props:{}">
On the front end, Inertia reads this page
object to get props
and the current component name (here homepage
).
createInertiaApp({
resolve: name => require(`./Pages/${name}`),
setup({ el, App, props }) {
render(<App {...props} />, el)
},
})
So the require
line automatically import ./Pages/homepage.js
component.
in CLJS, I think we can't rely on file-based routing or easily use the require like in JS so for now I manually "link" the component name with cljs symbols like here: https://github.com/prestancedesign/pingcrm-clojure/blob/main/src/cljs/pingcrm/app.cljs#L18-L34
Ideally, what I want to accomplish is to be able to make this dynamic. Perhaps an automatic import of namespaces via a macro would also be a solution. I will continue to search. Thanks for your time and help.
the struggle with integration in some other JS build systems is that they almost always rely on filesystem structure
since they don't have a proper namespacing system that is the somewhat obvious thing to do of course
Thanks for your insights, it's always very helpful!
Thank you very much for these precisions. I'm going to test different solution to see what's the best one.