This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-14
Channels
- # adventofcode (1)
- # babashka (60)
- # beginners (107)
- # calva (11)
- # cider (3)
- # clara (11)
- # clj-kondo (6)
- # cljs-dev (33)
- # clojure (70)
- # clojure-dev (4)
- # clojure-europe (3)
- # clojure-italy (2)
- # clojure-kc (1)
- # clojure-losangeles (12)
- # clojure-nl (4)
- # clojure-spec (32)
- # clojure-uk (35)
- # clojuredesign-podcast (1)
- # clojurescript (28)
- # core-logic (4)
- # cursive (5)
- # datomic (34)
- # devcards (1)
- # emacs (16)
- # events (13)
- # fulcro (15)
- # graalvm (5)
- # graphql (3)
- # jobs (8)
- # joker (2)
- # kaocha (17)
- # malli (6)
- # music (3)
- # off-topic (58)
- # protorepl (7)
- # re-frame (28)
- # rewrite-clj (9)
- # shadow-cljs (102)
- # spacemacs (3)
- # sql (20)
- # tools-deps (9)
@pez just wanted to say thanks for https://github.com/PEZ/rn-rf-shadow , got this up & running fast. a bit easier than my previous experience using re-natal I see that the README notes source-maps aren't working, but according to https://clojureverse.org/t/upgrading-the-react-native-support/4669/21 they might be after shadow-cljs 2.8.44. Will report back with my findings tomorrow
@quest , cool! I get a bunch of warnings and errors when starting things up, but things work. Do you have those messages as well, or have you found out how to fix it?
This is related, me thinks: https://github.com/PEZ/rn-rf-shadow/issues/7
I don't have the log from starting up, but I did notice a lot of deprecations & some other warning that seemed concerning. The app is working, though
I can confirm that source maps & breakpoint debugging work in Chrome after Enable Remote JS Debugging
is checked per https://facebook.github.io/react-native/docs/debugging (`CMD + M` on OSX.)
Nice work @thheller
In the shadow-cljs user guide (Section 4.1 Source Paths), it says: > It is not recommended to separate source files by extension (eg. src/clj, src/cljs, src/cljc). For some reason this is widely used in CLJS project templates but it just makes things harder to use. https://shadow-cljs.github.io/docs/UsersGuide.html#_source_paths I've always done this for two reasons, first to make it easy to specify what's included in my frontend and backend builds, but also just to have things nicely separated when I'm developing. I'd be interested to hear why shadow recommends not to do this? I'm always up for simplifying things
@conan splitting source paths makes sense sometimes. splitting by file extension does not IMHO. say you write a macro file for CLJS that is never used in CLJ. do you put it in src/clj
just because? src/cljc
just makes sharing annoying too. I pretty much always use setups like src/main/my/amazing/frontend/*
and src/main/my/amazing/server/*
still easy to separate out files when building uberjars etc. just exclude my/amazing/frontend*
I like the idea of being explicit about what each folder is for though, with frontend
and backend
for example. I've never come across a situation where that wasn't a 1:1 mapping with file extension though
Anyway, this all feels like preference, so it's good that there's lots of flexibility. There's no technical advantage as far as shadow is concerned though?
I can definitely see how the macro situation would cause me to rename my folders though
shadow-cljs doesn't care what the names are as long as the source-path is setup correctly
also https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html
Hey guys,
Was there any significant change in the websocket connection from the browser to the repl from 2.8.68
to 2.8.69
? If I do the update, my application doesn't connect to the repl anymore :thinking_face:
This message does not show up on the browser console in 2.8.69
to me:
shadow-cljs: WebSocket connected!
browser.cljs:26 shadow-cljs: REPL session start successful
I wish I had more useful information, but this is what appears in my browser's console in 2.8.69
:
Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
client.cljs:356 Installing Fulcro Inspect {}
This is what appears in 2.8.68
:
Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
client.cljs:356 Installing Fulcro Inspect {}
browser.cljs:26 shadow-cljs: WebSocket connected!
browser.cljs:26 shadow-cljs: REPL session start successful
Is there something I can do to provide more helpful context?In 2.8.68 I'm able to connect emacs to the repl using CIDER. In 69, I get a "no client connected to the repl" sort of message and I can't evaluate stuff
I will take a look on the network tab. Didn't try it before, just a sec
you can try checking if shadow.cljs.devtools.client.browser
exists in the browser console?
Ok, so, on 2.8.69
, there is no websocket connection attempt on the network tab in the console, and shadow.cljs.devtools.client.browser.cljs
is loaded in the browser (prints in the thread)
Printscreens in the slack thread xD
if that namespace is loaded it should have connected directly on startup? no clue why it wouldn't have?
Yes, the reference exists
If I type shadow.cljs.devtools.client.browser.cljs
in the console, I get an object back
oops, excuse me. Yes, without the .cljs
suffix
undefined
hit up shadow-cljs clj-repl
then (
. I'm guessing you have an old closure-library version
Yes, we do use lein
here!
shadow.user=> ( "goog/base.js")
#object[java.net.URL 0xdad8889 "jar:file:/Users/lucas.barbosa/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"]
we do have a mismatch :thinking_face:
[com.google.javascript/closure-compiler-unshaded "v20191027"]
[org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
[org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
the .env/enabled
is a goog-define and goog.define
was changed in the latest closure compiler/library release
shadow-cljs displays an empty error message when I do something stupid with macros:
;; test.clj
(defmacro dummy []
`(defmulti x ~identity))
;; test.cljs
(dummy)
The error:
------ ERROR -------------------------------------------------------------------
File: /.../test.cljs
Error in phase :compilation
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Not sure if that could be handled at all.I’ll try the dependency bump and let you guys know! Thanks for the awesome support @thheller !
Is there a way to not include a component in a release build? I guess other than module splitting, some sort of function/macro that depends on :shadow.build/mode
Are you using advanced? If so, you can just rely on dead code compilation. Here is an example: https://github.com/day8/re-frame/blob/69a3fcd411369fff65404e7d6a924ce1968e2dba/src/re_frame/registrar.cljc#L37-L39
( and here is debug-enabled?
: https://github.com/day8/re-frame/blob/accc559010c8635020fb929f1a4b081b69f58d5f/src/re_frame/interop.cljs#L16 )
I’m trying to implement code splitting based on https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html , but instead of reagent I’m using hx. Everything works fine, but hot reloading doesn’t seem to work. Shadow does detect the changed code, and does reload the changed namespace, and does call the “after-load” fn, but then React seems to skip over rendering the lazy component.
I’m using the “trick” to wrap the component in an extra level, but doesn’t seem to have any effect.
@orestis what did you try? the demo.util used in that post should be working with hot-reload
(defn lazy-component* [loadable]
(React/lazy
(fn []
(js/console.log "still lazy?")
;; React lazy expects a promise, that returns an ES6 module with a React Component as default export
(-> (shadow.lazy/load loadable)
(.then
(fn [root-el]
(if-not js/goog.DEBUG
;; in production mode, just do that
#js {:default root-el}
;; in dev mode, we need wrap the loaded component one
;; extra level so live-reload actually works since React
;; will keep a reference to the initially loaded fn and
;; won't update it
#js {:default (fn [props]
(js/console.log "lazy render")
(js/console.log (@loadable #js {}))
(React/createElement @loadable props)
(hx/f [LazyComponentWrapper {:loadable loadable :props props}])
(hx/f [LazyWrap {:loadable loadable :props props}])
)})))))))
That’s what the LazyComponentWrapper thing does, but it doesn’t seem to have any effect.
(hx/defnc LazyComponentWrapper [{:keys [loadable props]}]
(js/console.log "LOADABLE dereffed" @loadable)
[@loadable (bean props)])
I’m knackered for the day, but thanks for the confirming the general approach — return a wrapper that will deref the loadable on every render, to get the latest version.
trying to write a description of the component stuff I've been working on and vscode just deleted half of it ...
seriously .. I don't even know how it got into the state it is in now ... pressing undo/redo just makes arbitrary changes and makes things worse
Is this in a regular editor? Are you using macos? Checking because I have similar issues in Calva's REPL window, but only on Mac.
are you using vim-mode? i heard it has wierd interactions with the normal undo/redo system
I can confirm that source maps & breakpoint debugging work in Chrome after Enable Remote JS Debugging
is checked per https://facebook.github.io/react-native/docs/debugging (`CMD + M` on OSX.)
Nice work @thheller