This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-04
Channels
- # announcements (7)
- # babashka (32)
- # beginners (106)
- # bristol-clojurians (10)
- # cider (6)
- # clj-kondo (5)
- # cljdoc (10)
- # clojure (110)
- # clojure-australia (10)
- # clojure-dev (6)
- # clojure-europe (12)
- # clojure-nl (2)
- # clojure-norway (16)
- # clojure-spec (9)
- # clojure-uk (59)
- # clojurescript (105)
- # community-development (2)
- # conjure (46)
- # cursive (12)
- # data-science (1)
- # datalog (26)
- # datomic (37)
- # docker (4)
- # emacs (10)
- # events (1)
- # fulcro (8)
- # graalvm (2)
- # jobs (1)
- # jobs-discuss (1)
- # malli (24)
- # meander (13)
- # off-topic (52)
- # pathom (4)
- # polylith (17)
- # proletarian (4)
- # react (1)
- # rewrite-clj (4)
- # shadow-cljs (56)
- # sql (21)
- # xtdb (14)
I guess it was because of stream-browserify dependency. After uninstalling it, this is what I get:
The required JS dependency "stream" is not available, it was required by "node_modules/cipher-base/index.js".
Dependency Trace:
humboi/app.cljs
humboi/core.cljs
humboi/events.cljs
node_modules/@alch/alchemy-web3/dist/cjs/index.js
node_modules/web3/lib/index.js
node_modules/web3-eth/lib/index.js
node_modules/web3-eth-accounts/lib/index.js
node_modules/crypto-browserify/index.js
node_modules/create-hash/browser.js
node_modules/cipher-base/index.js
and npm i -s stream
makes no difference
please verify by checking <project>/node_modules/shadow-cljs
. this should also ensure that <project>/node_modules/node-libs-browser
exists?
stream is one of those built-in node packages that needs polyfills for browser builds which should be present if you have shadow-cljs installed in the project
yes itโs installed:
prikshetsharma@Prikshets-MacBook-Pro humboi % ls node_modules/shadow-cljs
README.md cli node_modules package.json
this is again related to the stream-browserify
package. did you sort of the version conflict? or which version of shadow-cljs do you use?
I donโt know what the version conflict is if any
nevermind it started working after installing and uninstalling a bunch of packages
I am trying to make React optional for an :esm
module, so that the npm installed one will be used instead of using a built-in version of React. I thought I could do this with:
{:deps true
:builds {:modules {:js-options {:keep-as-import #{"fs" "module" "path"}
:resolve {"react" {:target :global
:global "React"}
"react-dom" {:target :global
:global "ReactDOM"}}}
:compiler-options {:infer-externs :auto}
:target :esm
:runtime :node
but what I'm getting in this case is:
shadow-cljs - failed to load 0
ReferenceError: React is not defined
:keep-as-import
just tells the compiler to not bundle a thing and instead let the runtime import
sort it out (so node in your case)
since React only ships commonjs ["react" :as react]
might not work, might need to be ["react$default" :as react]
as long as shadow-cljs bundles the commonjs is not a big problem but once it doesn't it might be
that's fine. it seems it works as is, but I'm getting an advanced compile error.
^
TypeError: d.Sf is not a function
at x8.$APP.g.flush_render (file:///private/tmp/tbd/out/nbb_reagent.js:44:344)
at x8.$APP.g.flush_queues (file:///private/tmp/tbd/out/nbb_reagent.js:43:313)
at x8.$APP.g.run_queues (file:///private/tmp/tbd/out/nbb_reagent.js:43:414)
at Timeout.a [as _onTimeout] (file:///private/tmp/tbd/out/nbb_reagent.js:43:50)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
when shadow-cljs doesn't bundle the JS dependencies the externs it usually infers from doing so are also missing
so sometimes needs a hand. usually just a few words in https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs is enough
debug is just :pseudo-names true
and :source-map true
? that shouldn't affect externs related things
not sure, but it could be from here: https://github.com/reagent-project/reagent/blob/c214466bbcf099eafdfe28ff7cb91f99670a8433/src/reagent/impl/batching.cljs#L85
That does seem to have done the trick. I have put
nbb/externs.txt
with:
componentQueue
and now it works...What's the best practice on source maps? The source maps in my project are way bigger than the sources itself. I guess I should remove them when publishing the package?
hmm, it seems when depending on a keep-as-import
-ed "react"
, it won't use a local react.
$ nbb ink-demo.cljs
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'react' imported from /usr/local/lib/node_modules/nbb/out/nbb_reagent.js
Perhaps I should just split out the reagent module into a separate npm package and just depend directly on react there, without keep-as-import.(since the reagent module is 'required' using import, it doesn't use the createRequire-ed logic, and I haven't found out a way to fix this yet)
I tried dynamic importing react from the script-relative path before dynamic importing reagent itself, but it seems reagent still wants to load react from the nbb installed relative path
I think the user should be able to install react into the globally installed nbb node-modules, as a choice.
ok, it seems this works. npm install -g nbb --no-optional
now doesn't install react
it might be nicer if npm had a finer-grained way of saying: I want only optional dep this and that, but ok
Is there a way to watch
without live reloading? I'm trying out Pulumi for infrastructure as code and have been successful using compile
but that's a longer feedback cycle. When using watch
shadow is waiting to make a connection I think via a websocket when I run pulumi up
. Looking for a way for watch
to only compile the code, not reload.
:devtools {:enabled false}
on your build does this I think
My goal is to try devcards (or anything like it really), what is setting the compiler-options to devcards doing in this example from the docs?
;; Here is some dev-specific config
:dev {:compiler-options {:devcards true}}
You can get a live devcards pretty easily with sci
which is quite cool. Obviously misses lots of things but I think its promising https://martinklepsch.org/100/interactive-design-system-docs.html