This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # adventofcode (1)
- # announcements (1)
- # babashka (5)
- # beginners (344)
- # bristol-clojurians (1)
- # calva (18)
- # cljfx (6)
- # clojure (85)
- # clojure-europe (37)
- # clojure-finland (1)
- # clojure-france (2)
- # clojure-nl (2)
- # clojure-taiwan (3)
- # clojure-uk (17)
- # clojurescript (13)
- # conjure (23)
- # cursive (25)
- # datomic (7)
- # fulcro (62)
- # java (7)
- # jobs-discuss (6)
- # malli (3)
- # off-topic (22)
- # portal (18)
- # reagent (34)
- # reitit (8)
- # releases (3)
- # shadow-cljs (18)
- # tools-deps (1)
@thheller If I’m compiling
:node-library is there any way to do dynamic module loading? I’m working on a hybrid client / server ssr tool for cljs akin to next js. I have library code that I want to
require client modules and for this to work on both the client and the server. The main issue I can forsee is if I try to have multiple entry points on the server. Any comments?
For more context:
• The tool is called clam.
• I have a node cli with a
clam dev command that spawns a clj process, which then starts a shadow server and call
watch* with 2 generated build configs.
• I generate 2 builds, a client and a server.
:target :browser and
target :node-library , currently these both import client react trees, with the server one adding http handlers and ssr.
• I want to augment this to support dynamic module loading on the client and control the loading experience. The issue I can see is that since its no longer a single
require tree, I dont know how that will play with node-library
but I don't quite see how server side stuff relates to client side stuff in any way?
Thanks Thomas. Does :esm support repl and hot reloading? It’s more loading and executing client code on the server, but if the client code has dynamic module loading then It seems this is no longer possible
I don’t mind doing some custom build stuff to get this working, since I completely control the build step
@mail024 it entirely depends on how you do the dynamic module loading stuff. its code in your control so you can just write one implementation for the browser and one for node.
esm does support REPL and hot-reload yes but you really should use two separate builds and not try to make one build do two things
I definitely have 2 builds. I guess what I’m asking is if its possible to do dynamic module loading, inline require in node using cljs
how you load them is your concern. one option is to use
shadow.loader which only works in
:browser builds. you do not have to use that though. you can completely roll your own that works in both browser and node
right! thanks for the clarification, I guess I assumed the
.js files outputted assumed a browser environment. Or that the files outputted with other builds don’t work without entries, etc.