This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-23
Channels
- # announcements (3)
- # architecture (10)
- # babashka (37)
- # beginners (69)
- # calva (2)
- # cider (10)
- # clerk (22)
- # clj-kondo (33)
- # cljdoc (44)
- # clojure (45)
- # clojure-conj (4)
- # clojure-denmark (7)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (4)
- # clojurescript (10)
- # clr (19)
- # conjure (1)
- # emacs (28)
- # events (1)
- # fulcro (1)
- # jobs (1)
- # joyride (1)
- # lsp (18)
- # malli (30)
- # membrane (3)
- # off-topic (23)
- # pathom (45)
- # portal (29)
- # proletarian (7)
- # rdf (15)
- # re-frame (21)
- # reagent (2)
- # releases (6)
- # remote-jobs (1)
- # reveal (6)
- # shadow-cljs (36)
- # slack-help (7)
- # sql (5)
- # tools-deps (3)
I'm trying to use webpack to handle dynamic imports, following https://github.com/aratare-jp/shadow-cljs-require/tree/solution But I'm getting this in my console
Uncaught TypeError: shadow.js.shim.module$create_react_class is not a function
Relevant parts of the shadow-cljs config:
{:target :browser
:compiler-options {:output-feature-set :es6}
:output-dir "public/js"
:asset-path "js"
...
:js-options {:js-provider :external
:external-index "target/index.js"}}
Then I invoke webpack with the following command:
npx webpack --entry ./target/index.js --output-path ./public/js --output-filename libs.js
My index.html has script tags ordered like so
<script src="/js/libs.js"></script>
<script src="/js/main.js"></script>
<script>shadow_cljs_require.core.init();</script>
Yet I get the TypeError above. Why?after closer inspection, it looks like my :asset-path
is problematic and I wont be able to do much as a consequence of relative paths from URLs being unsupported
what do you mean unsupported? they work just fine and would not cause the error above?
are you sure main.js
is the correct file? you elided the :modules
? could be some old file sitting arround?
What I mean by relative to the URL is here https://github.com/thheller/shadow-cljs/blob/22c3f41f86a5ba4754eb774da9c03ec91043d897/src/main/shadow/boot/browser.js#L16
This is the structure dev tools in firefox are able to see. And nothing seems wrong with my HTML file. Interestingly, another webpack sample project that uses :target :npm-module
works flawlessly on my machine, but using :js-provider :external
hasnt been able to work
shadow.js.shim.module$create_react_class is not a function
this error is NOT from the :js-provider :external
build
I see. I've just deleted all build artifacts and the .shadow-cljs
folder. Hopefully this works
Testing in a fresh copy of Chromium. Looks like Firefox does not provide this information whatsoever. This seems to point out the problem
Looking at the chunks webpack placed into public/js, I indeed don't see React anywhere in there. That probably explains my issue -- need to make webpack aware of the transitive React dependency (which I find strange because it's in my package-lock.json and node_modules folder)
Ok yeah it's definitely me not adding the necessary require()
statements. I had to include e.g. (:require ["react" :as react])
in my core.cljs file so that the following can be emitted
ALL["create-react-class"] = require("create-react-class");
ALL["react"] = require("react");
ALL["react-dom"] = require("react-dom");
then running webpack once more produces a libs.js that contains everything core.cljs wants
I would've never figured this out if you didn't tell me to ensure browser cache wasn't messing with my build 🙂you shouldn't need to add any requires? I mean if you use reagent or whatever it would already provide the react require?
Well, the version of reagent in the project I cloned is pretty outdated (0.8.0-rc1), and that version seems to want to use CLJSJS React instead of an NPM React
I'm trying to use my webserver over SSL, which works, except that shadow does not want to connect. I've created a keystore and am adding this to the shadow-cljs command line --config-merge '{:ssl "docker/keystore.jks" :password "shadow"}'
, but it still fails and I get this error in the js console:
WebSocket connection to '' failed:
I'm guessing that it should be wss
, but don't understand how to make it so. I note that the config merge seems to do something because when I add it, I get automatically redirected to https, from http, which does not happen without the merged config.Changing the devtools-url to use https like so "https://localhost:9630", changes the error message to say that wss://
, but there's no info about how it fails. Can I enable some verbosity somehow?
So, config-merge map is now {:ssl {:keystore "<path-to-keystore>" :password "shadow"}}
, :face_palm: , but I still don't get it to work...
OK. So it seems I can't add this via config-merge
like that. If I move it to the shadow-cljs.edn
file, it works.
I'd like to not enforce ssl on other devs on the project. Is there some other way I can achieve that?
It works fine accessing things without https still, I now notice. It was when I was using the config merge that it started redirecting me to https, :ssl <something>
means something else in the build config.
if :devtools-url
is set that is used. as-is. if not it tries to figure out which url to use from document.location
in the client. it only uses ssl if ssl is configured in shadow-cljs
Yes, I meant that when I had misunderstood config merge, I tried to provide the ssl params that way, and it caused the browser to redirect http->https. So it means something, it seems.
I very confident that :ssl
has no effect in the build config, regardless of if coming from config direct or config-merge. but if you want to setup a repro I'll take a look.
Next question. 😃 I'm accessing the app using my iPhone pointed at the network name for my machine. The app loads and works, but shadow tries to connect to localhost. How can I make it connect to the network name instead?