This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-25
Channels
- # announcements (30)
- # beginners (4)
- # calva (173)
- # cider (22)
- # clj-kondo (12)
- # clojure-austin (2)
- # clojure-brasil (1)
- # clojure-europe (56)
- # clojure-korea (1)
- # clojure-nl (1)
- # clojure-norway (53)
- # clojure-uk (5)
- # clojurescript (25)
- # data-science (82)
- # hyperfiddle (87)
- # introduce-yourself (11)
- # jobs-discuss (44)
- # malli (4)
- # off-topic (7)
- # pedestal (8)
- # re-frame (16)
- # releases (1)
- # shadow-cljs (41)
- # slack-help (5)
- # sql (1)
- # squint (1)
hey I'm using the :graaljs
build target to do some React SSR but it looks like shadow pulls in the browser build of react-dom
? I see this when I eval in GraalJS
shadow-cljs - failed to load module$node_modules$react_dom$cjs$react_dom_server_browser_development
I tried the
:js-options {:resolve {"react-dom/server" {:target :npm
:require "react-dom/server.js"}}}
thing. But compilation fails with package react-dom had exports, but could not resolve ./server.js
. That doesn't seem to be true from looking at my node_modules
. I'm actually not sure if that's how this option is even supposed to be used, though.:resolve
affects the build, but shadow-cljs - failed to load
is a runtime error. it pulled in the correct file already, it didn't need help on that front
graal is a shitty JS engine and I do not recommend using it. you'll have much more luck with node
@thheller I thought I might share a shadow-cljs+WASM success since we spoke about it a month or so ago: https://github.com/manetu/lambda-sdk-clj
well if you are setting :custom
but don't actually provide any then you might as well just set :devtools {:enabled false}
just disabled the devtools entirely, so in essence the same as :runtime :custom
and not actually setting :devtools {:client-ns ...}
the idea behind :runtime :custom
is that you can provide an implementation that can connect back to the shadow-cljs websocket and provide REPL/hot-reload
I didnt see any material changes good or bad, so I went forward with your suggestion: https://github.com/manetu/lambda-sdk-clj/pull/5
note that its disabled for release
builds anyways, so technically you don't even need that
Hey folks. I'm trying to port a reagent SPA I have to https://single-spa.js.org/, for reasons outside of my control. It looks like single-spa uses https://github.com/systemjs/systemjs, which is able to load its own systemjs modules as well as UMD modules. This leads me to wonder what the heck type of module I'm getting when I use shadow and target :browser
. I've been digging around the shadow docs, issues, and threads in here to answer my questions, but I'm still unsure on this one specifically. shadow doesn't seem to use the same JS terminology for these modules as the mainstream JS tooling.
the output is equivalent to whatever the closure compiler emits, with some hacks employed by shadow in order to prevent npm code from going through advanced optimizations
I think you may be able to port the reagent SPA by using :js-provider :external
then relying on webpack to produce UMD output
this guide seems useful for that https://remarkablemark.org/blog/2016/09/22/webpack-build-umd/
Thanks for the response. If I need to go through webpack, I can have it output systemjs modules.
> We recommend a setup that uses in-browser ES modules + import maps (or SystemJS to polyfill these if you need better browser support). This setup has several advantages:
:js-provider :external
is only concerned with packages JS dependencies, so it would do nothing to integrate the CLJS code into the systemjs model
technically there could be a :target :systemjs
since that is what this whole target abstraction is for, "wrapping" outputs to integrate into other systems. it isn't however exactly trivial to write one and I have never looked into what systemjs actually is
Thanks so much for the breakdown. Yeah, not seeing :systemjs
support was not a surprise, since it's just yet another way to do modules in JS. I'll give :esm
a go and hope that it's enough.
note that by default :esm
will try to bundle all dependencies, for those it should not bundle you can set :js-options {:keep-as-import #{"react"}}
, so that they remain as regular import
and work with importmaps as the recommended setup suggests
Ah, so I don't need to do something like:
:js-options {:resolve {"react" {:target :global
:global "React"}
"react-dom" {:target :global
:global "ReactDOM"}}}
you can also set :js-options {:js-provider :import}
which will everything as import
and don't bundle any npm deps