This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-29
Channels
- # aws (8)
- # babashka (45)
- # beginners (83)
- # cider (23)
- # clj-on-windows (4)
- # cljdoc (23)
- # clojars (6)
- # clojure (68)
- # clojure-dev (33)
- # clojure-europe (75)
- # clojure-nl (1)
- # clojure-uk (4)
- # clojurescript (14)
- # conjure (6)
- # data-science (15)
- # datascript (7)
- # datomic (47)
- # docker (15)
- # events (1)
- # fulcro (4)
- # graphql (3)
- # jobs (4)
- # lsp (14)
- # nginx (2)
- # nrepl (2)
- # off-topic (41)
- # pathom (18)
- # pedestal (1)
- # polylith (72)
- # reitit (8)
- # reveal (1)
- # shadow-cljs (48)
- # tools-build (11)
- # tools-deps (24)
- # xtdb (8)
@arohner it is not supposed to find tests in jar files. otherwise it'll also start testing code from libs that accidentally bundled their tests, not all too common but does happen. why does bazel all of the sudden need .jar files? the last time I talked to someone about bazel it needed files and even extracted regular .jar files?
definitely no on the tools.namespace
. you can always create a namespace that requires all your tests and use :entries [that.collect-ns]
or just :entries [my.foo-test my.bar-test]
or use a script or something to generate that.collect-ns
for you. just needs to be (ns that.collect-ns (:require my.foo-test my.bar-test))
etc
Is there an equivalent of checkouts
from lein when using shadow-cljs? My use case is that I am developing a library on my local that I will eventually put into clojars and I have a few projects that are consuming the same library. At the moment I am using symlinks from the src
directory but I wonder if there is a better way?
i can make it work with a deps.edn in the lib and no lein?
shared.js:1552 TypeError: Super expression must either be null or a function, not undefined
at _inherits (control.js:26)
at eval (control.js:50)
at Object.shadow$provide.module$node_modules$react_leaflet_control$dist$control (control.js:49)
at Object.shadow.js.jsRequire (js.js:66)
at Object.shadow.js.require (js.js:113)
at eval (quagga.components.dataview.map.view.js:4)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:486)
at Object.env.evalLoad (shared.js:1549)
at tabbed-dataview.js:250
my code looks something like this
[:<>
[:> TileLayer {:url "https://{s}.}]
[:> ZoomControl {:position "bottomleft"}]
[:> Control [:button "click me"]]
[:> FeatureGroup
(map
(fn [position] [:> Marker
{:position position,
:key position,
:eventHandlers {:click (fn [e]
(js/console.log
(-> e
.-target
.-_latlng)))}}])
geopoint-positions)]]
I'm starting to think it's something that's wrong with the package that's the cause for this; maybe it's not compatible with shadow-cljs?
@USWTQB9RU I think the components TileLayer, ZoomControl etc need to be inside a Map component. For Example: This worked for me
(ns example.views
(:require
["react-leaflet-control" :default Control]
["react-leaflet" :refer [Map TileLayer ZoomControl]]
(defn main-panel [style]
[:div {:style style}
[:> Map {:center [51.3 0.7] :zoom 10}
[:> ZoomControl {:position "topright"}]
[:> TileLayer {:url "http://{s}."
:maxZoom 18}]
[:> Control {:position "topleft"}
[:button "click me"]
"Reset View"]]])
this is from https://www.npmjs.com/package/react-leaflet-control I ported the example to cljsthanks @U02806HQX1C 🙂 . I actually did put them them inside a MapContainer component that wraps the component I pasted up here ☝️ . On the other hand, I later also found a workaround where I don't need to use this library. but I still am curious as to why I get the above error
Cool. I got similar error when I used the Control component in isolation. So, I thought that might be the issue.
Hi @thheller
I am playing with the excellent rn-rf-shadow
React Native project and facing issues with live reload
The project structure is as below
;; app.cljs
(ns
(:require [example.events]
[example.subs]
[expo.root :as expo-root]
["react-native" :refer [View]]
[example.screens.home :refer [home-screen]]))
(defn root []
[:> View
[home-screen]])
(defn start
{:dev/after-load true}
[]
(expo-root/render-root (r/as-element [root])))
...
;; screens/home.cljs
(ns example.screens.home
(:require ["react-native" :refer [SafeAreaView Text]]
[example.components.image :refer [image]]))
(def clojure-image (js/require "../assets/images/clojure.png"))
(defn home-screen []
[:> SafeAreaView
[:> Text "Hello World"]
[image clojure-image]
;; components/image.cljs
(ns example.components.image
(:require ["react-native" :refer [Image View]]))
(defn image [user-image]
[:> View {:style {:height 46
:width 46}
[:> Image {:source user-image
:style {:height 40
:width 40}}]])
Live reloading for any change I make in home.cljs or app.cljs is working perfectly fine. But isn’t working for changes in image.cljs I will have to do some dummy change in home.cljs everytime for the live reload to work.
I see that this was already asked here https://github.com/thheller/shadow-cljs/issues/544, but the specified solution only works for children (imported) in app.cljs
I tried ^:dev/always
to app namespace like so (ns ^:dev/always )
and that doesn’t seem to work either.
Is there any solution for this. Am I missing something ?It would be this https://github.com/PEZ/rn-rf-shadow/blob/master/src/main/expo/root.cljs
I’ve used [shadow.expo :as expo]
from your reagent-expo example and the behaviour is same.
(ns
(:require [shadow.expo :as expo]
[re-frame.core :as rf]
["react-native" :refer [View]]
[reagent.core :as r]
[example.screens.home :refer [home-screen]]))
(defn root []
[:> View
[home-screen]])
(defn start
{:dev/after-load true}
[]
(expo/render-root (r/as-element [root])))
(defn init []
(rf/dispatch-sync [:initialize-db])
(start))
Seems like an extension of this issue https://github.com/thheller/shadow-cljs/issues/544#issuecomment-521662073
Adding {:dev/after-load true}
as suggested in the issue
;; app.cljs
(defn start
{:dev/after-load true}
[]
(expo/render-root (r/as-element [root {:x (js/Date.now)}])))
Only works for changes in imports (children) of app.cljs
But don’t work for grandchildren.
Strange that this doesn’t happen for web development and only for react-nativeyou can set :devtools {:reload-strategy :full}
in your build config to reload many more files than it usually would
but the issue is not with shadow-cljs. it is reagent/react deciding to stop to render
ie. when you only edit image.cljs then [root]
didn't change. so reagent/react decide they can stop rendering completely and never get to the actual image
which actually changed
> well did you try the suggestion with using an extra variable?
You mean adding {:dev/after-load true}
Yes I’ve tried this. Same behaviour.
> you can set `:devtools {:reload-strategy :full}` in your build config to reload many more files than it usually would This worked… 🙏
the :dev/after-load
just tells shadow-cljs which function to call after its done reloading code. you need that regardless
the :x
would be the "hack" to force reagent/react to actually render the component and not skip it
> I meant this `[root {:x (js/Date.now)}]` Oh right. My bad, sorry :face_palm: This worked.
➜ malli-ts git:(master) ✗ node
Welcome to Node.js v14.17.6.
Type ".help" for more information.
> let malli_ts = require('malli_ts.ts')
Uncaught TypeError: Cannot read property 'Error' of undefined
at Object.<anonymous> (/home/tiago/Documents/side-projects/malli-ts/node_modules/goog.debug.error.js:38:29)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
The build config I'm using:
{:target :npm-module
:output-dir "node_modules/"
:entries [malli-ts.ts]}
It is compiling successfully but failing to import the module 😕
I just spent some time tangling with cljs->node, you might try wrapping the output from the compiler in this UMD wrapper: https://groups.google.com/g/clojurescript/c/vNTGZht1XhE
@U4U6BDQTE which shadow-cljs version? this should be fixed in the latest?
@U028BUU1P3R that code is ancient history and not relevant anymore
oh thanks!
I did switch to :node-library
and it's working fine 🙂
If I have npm modules that I am using via npm link
is there any way to get shadow to hot reload them as the bundle for that linked package is updated?
shadow only watches package.json
files for changes, so if you touch package.json
it should update
This worked, thank you so much! 🎉