This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-07
Channels
- # announcements (11)
- # architecture (2)
- # babashka (84)
- # beginners (226)
- # calva (7)
- # chlorine-clover (4)
- # cider (29)
- # clara (17)
- # clj-kondo (23)
- # cljs-dev (58)
- # cljsrn (60)
- # clojure (172)
- # clojure-europe (24)
- # clojure-finland (2)
- # clojure-italy (6)
- # clojure-nl (8)
- # clojure-spec (4)
- # clojure-uk (22)
- # clojurescript (44)
- # conjure (39)
- # core-async (64)
- # cursive (76)
- # data-science (15)
- # duct (3)
- # emacs (2)
- # events (5)
- # fulcro (30)
- # helix (4)
- # jackdaw (5)
- # juxt (1)
- # kaocha (1)
- # leiningen (4)
- # off-topic (9)
- # pathom (22)
- # re-frame (9)
- # reagent (33)
- # reitit (3)
- # ring (10)
- # ring-swagger (2)
- # shadow-cljs (192)
- # spacemacs (27)
- # specter (2)
- # sql (59)
- # vim (2)
Hi all, in shadow-cljs .edn
if I depend on Reagent I have to use npm install [email protected] [email protected] create-react-class
to install it’s dependencies, but they are mentioned in Reagent’s package.json
. Same for npm packages that have dependencies in package.json
, for some reason I have to add them manually. Is there a way to retrieve transitive dependencies automatically?
Hi, i've a problem on hot reloading application on android device. My app is based on rn-rf-shadow (shadow-cljs, expo, reagent) https://github.com/PEZ/rn-rf-shadow . The hot reload has worked before. I think it has stopped as expo client updated react native and introduced fast-refresh. Fast-refresh is disabled on device. When I change my screen class the .cljs files are loaded and the start method is called.
load JS kickmanager/domain/start/start_screen.cljs
load JS kickmanager/domain/main/main_frame.cljs
call
This is the start function
(defn start
{:dev/after-load true}
[]
(expo/render-root (r/as-element [PaperProvider {:theme custom-theme}
[main-frame-with-socket]])))
Hope someone can give me a hint on what to investigate. Thx and regards.as far as shadow-cljs is concerned it did its job. why your client doesn't update I cannot say. after calling your start fn shadow-cljs is done and out of the picture
https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html
Danke Thomas, I will re-check with clean projects and ivestigate further (Costs so much time on side-projects 🙂 ). I’ve already tried swapping reagent atoms on start … but no success so far.
Works now. The fix was introducing the “dummy prop that always changes”, topic “Hooking up React” from the guide thheller mentioned above.
@erwinrooijakkers the dependencies should be installed automatically when starting shadow-cljs? reagent doesn't have a package.json
though so you just might be on a very old reagent version that doesn't declare its JS deps properly?
Does not happen
[reagent "1.0.0-alpha1"]
But the version before that had same problem
It’s this example project: https://github.com/transducer/zenroom-cljs-demo where I wanted to get Reagent + Zenroom (an npm package with a WASM file) to work
So I need to do this manually:
npm install [email protected] [email protected] create-react-class
npm install zenroom [email protected] regenerator-runtime
Yes zenroom as well
did you just miss the npm install
(without any packages) to install the dependencies listed in package.json
?
Maybe…
I mean nmp install zenroom && npm install
would work?
I want these transitive dependencies to be added
Without me doing it manually
I don't know why you are calling npm install zenroom
since that will just install zenroom but not the rest
but zenroom is listed in package.json so it will already be installed when you run npm install
Yes I mean when you don’t have a package.json yet
How you start from scratch
When I run npm init -y && npm install zenroom
i do not have the transitive dependencies
Then shadow-cljs complains
And I have to manually run npm install [email protected] regenerator-runtime
(Dependencies of zenroom)
Maybe i just dont know how npm works
if zenroom doesn't declare its dependencies properly then that has nothing to do with shadow-cljs?
They are mentioned here: https://github.com/DECODEproject/Zenroom/blob/master/bindings/javascript/package.json#L49
Okay that’s wrong…
That version of core-js doesn’t work
That’s the problem then
Thanks!
And in relation to Reagent, is there a way to automatically install it’s npm dependencies (`npm install [email protected] [email protected] create-react-class`)?
Let me check
I have Reagent added in shadow-cljs.edn
Then i run shadow-cljs watch app
And indeed running: yarn add [email protected] [email protected]
Automatically
Okay everything is cleared up
It does indeed
The problem was not Reagent or shadow-cljs
The problem was misconfigured zenroom package
I added an issue on that package and they’ll look into it. I am happy that I understand now what went wrong and that shadow-cljs is doing everything as hoped.
And @U05224H0W thanks a lot for thinking a long. I really appreciate the work your putting in shadow-cljs, it works supersmoothly, and also your active replies on people their problems here, like pinpointing my issue within a minute to be in the external package’s config.
Hi has anyone has come across this error when doing a release.
The required namespace "shadow.js" is not available, it was required by "node_modules/react/index.js"
I don't have this anywhere in my code nor do I have any clue why react is requiring it. I can get the app to compile by installing the npm package shadow.js (whatever that is, plus a dependency rxjs) and it will compile successfully, but then when loading the compiled javascript I get the error
uncaught ReferenceError: shadow is not defined
Appreciate any hints or help.shadow.js
is a helper namespace for npm JS interop. it comes with shadow-cljs. should be basically impossible that it doesn't exist?
do you use any kind of weird non-standard setup that may dynamically modify the classpath? ie. running in embedded? or boot maybe?
Yes running via a boot task, sorry should have mentioned it works fine via the command line. That would be important to know. I've spent the evening trying to hunt down class path conflicts. Unfortunately prefer to keep it in boot as its a step in a complicated deployment rpm/generation process. Task based on https://github.com/jgdavey/boot-shadow-cljs/blob/master/src/com/joshuadavey/boot_shadow_cljs.clj
don't know much about boot sorry. don't know how it even gets to a working state but then missing files that are in the exact same .jar
but I'm currently rewriting a bunch of classpath logic so it might accidentally fix that issue as well
Someone had the same error doing something with Karma back in 2018...doesn't jog a memory just on the off chance? https://clojurians-log.clojureverse.org/shadow-cljs/2018-08-22
uncaught ReferenceError: shadow is not defined
is the effect of the file missing in the first place
not sure how you ever get past the error of shadow.js missing but any attempt at hacking that together will make everything else fail
https://github.com/jgdavey/boot-shadow-cljs/blob/master/src/com/joshuadavey/boot_shadow_cljs.clj#L59
this is downright scary old. certainly hope that is not the version you end up using.
heh no I'm on your latest...
Fixed it! Thanks for posting that above. it got me thinking that the install-dependencies hook might not be working or doing the right thing in the right order. I added shadow-cljs to the main boot dependencies and its working finally!
Its more magic than rails is boot...
Hi, does shadow-cljs have any method of handling (private) git repos as dependencies? Or should I just opt for deps.edn? I couldn’t really find anything on this topic.
Hi, I have the following code in my cljc file:
#?(:clj (slurp (io/resource "my-web/test.txt"))
:cljs (resource/inline "my-web/test.txt"))
Is there a way to replace it with a single macro so this is easier to use? Not sure how to distinguish between Shadow-cljs and Clojure running the macro?@kevin.van.rooijen not supported. need to use deps.edn for that.
@pavel.klavik resource/inline
should work from clojure too although that would mean you'd have shadow-cljs as a runtime dependency so probably not recommended for CLJ
Ok, I can test that, I don't really care about runtime dependency since this is a library for static web compilation: https://github.com/OrgPad-com/volcano.
seem to work great, thx
btw. if I have an inline JS function defined in my html file:
<script>function f { ... }</script>
how can I call it from my Clojurescript call? I tried js/f
, but I get that it is undefined.should be fine. did you ensure that is defined before your own code tries to access it?
The script is defined above, and I have :on-click defined on the button div at the bottom.
[:div.button-filled #?(:clj {:onclick "f();"}
:cljs {:on-click #(js/f)})
"Odeslat"]
no, cljs. clj works fine
ya, I am producing a single hiccup for the entire page, so it contains both the script and the button
<script>function f() ...<script>
MUST come before <script src="js/foo.js">
(your compiled CLJS output)
ya, it happens like that:
script tag for f is produced by hiccup also right now
ya, makes sense, so what would be the solution? Is it possible to add some reflection call to on-click? Or should I split this and include the script before?
ok, so if I have a bunch of script files whose list is defined in runtime, how can I eval them? Should I call js/goog.global.eval on them?
basically, in development I need to somehow eval them, in building static web, I just need to inline them
so what should I call for that?
so how should I approach this to have hot code reloading?
I should put it into mount-root fn?
or just put it into the page directly? I assume you generate the base page from CLJ anyways?
hmm, ya, combination of these might work
things like static libraries (i.e., jQuery) can go into the page directly, and scripts you write and want to inline can be included using js/goog.global.eval. thx, will test this out
I don't quite understand what you are doing or why this stuff isn't part of the regular build though
it is a static website generator, where development runs as SPA using Reagent and Shadow-cljs, so you get hot code reloading, and then you build static website files
ya, nothing
I am trying to add some basic js support so you can have contact forms, etc., but nothing too big
ok I expected there to be some CLJS at runtime regardless. mostly because I wouldn't want to write any JS I guess 😛
ya, I feel the same, but basically the goal is to just have a few lines of JS for needed stuff, nothing big, and we want to optimize the download time
basically the idea is that I want the similar comfort as with Reagent and Shadow-cljs, but for developing static web
well the :advanced
CLJS build is basically the same size of jquery so thats no argument 😛
ya, I think I will probably get rid of jQuery as well, plain JS should be enough, but adding small amout of CLJS when you need to do more complicated stuff makes sense
ok, it seems to work, thx
heya all, I have a question if someone is around: is it possible to add configuration items to the default node-repl? In my specific case I'd like to add a :resolve
in :js-options
that would always be used in the node repl
there's no way to put it in shadow-cljs.edn
then I take it?
well you can use :build-defaults
or :target-defaults
(not documented anywhere though)
:target-defaults {:node-script {:js-options ...}}
would only apply to :node-script
builds
is that something that should be documented? I can add it to the docs
I guess the real question is not if it should be documented, is if you'd like to support it
node-repl should probably be configurable elsewhere too though. feels like a bad idea to try to abuse the defaults for that 😛
if it is part of the supported features, then it should be documented
I added it since I thought it might be a good idea but never actually used it anywhere 😛
I don't know how legitimate my case is really... we have a bunch of node and browser builds, and they share some code. In the shared code, there's an import to a JS library that only works in browser.
We added a resolve to redirect that require to a local js file that contains a stub. I would like to be able to say "for all builds but the browser build, resolve this library to the stub". That seems to be something that build-defaults
would do well.
at some point we tried to do the opposite: require the stub, and resolve the stub to the real library in the browser app, but that didn't seem to work
I didn't debug why though, maybe I was resolving it wrong or something
well the config merge is rather basic so there really no way to remove a :resolve
once its there
Am I right in thinking (it certainly seems to be the case) that if I already have a shadow-cljs server
running in another process, shadow-cljs watch :test
will not autorun tests?
ohhhh I’m an idiot sry, they’re run and the output is in the server terminal
yeah not ideal, but easy enough to work around
thanks
I assume it makes no difference if I just lean on the test watcher as the server, instead of starting one explicitly
testing will be different soon anyways I hope. working on something that should improve the situation a bit.
does the user guide have a repository where I could contribute that :build-defaults
bit to?
urf durf ⛄
just to be clear about the semantics
by this do you mean that config items cannot be removed, or cannot be overwritten?
e.g. if I set a resolve on build-defaults
can I overwrite it on my app
config?
does it go in toplevel config, or inside :builds
?
merge order is build-defaults -> target-defaults -> actual build config -> extra config merges
I'm a few steps behind that.
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[]
:builds
{:backend
{:target :node-script
:modules
{:main {:init-fn acme.backend.core}
:output-to "main.js"}}}}
Here's what I'm tryinghttps://github.com/shadow-cljs/shadow-cljs.github.io/pull/50 here's the docs pr for the defaults