This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-02
Channels
- # aleph (3)
- # announcements (2)
- # babashka (4)
- # beginners (74)
- # calva (21)
- # clj-kondo (30)
- # cljs-dev (7)
- # cljsrn (42)
- # clojure (121)
- # clojure-dev (13)
- # clojure-europe (23)
- # clojure-losangeles (2)
- # clojure-nl (2)
- # clojure-norway (7)
- # clojure-spec (140)
- # clojure-uk (58)
- # clojuredesign-podcast (9)
- # clojurescript (49)
- # clojutre (2)
- # cursive (32)
- # datascript (2)
- # datomic (59)
- # duct (7)
- # figwheel-main (6)
- # fulcro (18)
- # graphql (5)
- # jackdaw (1)
- # joker (6)
- # juxt (7)
- # leiningen (9)
- # off-topic (1)
- # pedestal (14)
- # quil (2)
- # re-frame (3)
- # reitit (8)
- # shadow-cljs (78)
- # sql (8)
- # timbre (3)
- # vim (69)
Hello everyone,
Background
I have a question regarding the way shadow-cljs
handles browser connections - I experimented with connection an app to chromium
and firefox
, the chromium
app was the one running, when I did (shadow/repl :main)
and later I opened the same localhost
in the firefox
one.
Curiosity
I was wondering whether there’s a way to inspect
the network calls
in both browsers. From my initial experimentation it seems that the level of integration is definitely tighter with the first browser where I connected with (shadow/repl :main)
.
I read the shadow-cljs user guide
but couldn’t find any config as such - please let me know if it’s possible or not.
not really sure what you are asking. the REPL only ever talks to one browser (typically the first one connected).
Hi @U05224H0W, That is what I concluded as well, I was just curious whether it was possible to replicate the same session in two browsers or not.
no it is not. too many things that could go wrong if they connect at different times and miss a command or so
Hmm, interesting. Thanks for the clarification @U05224H0W 👍
so if you triggered the request from the REPL then only one browser will do that request
I’m getting an error when trying to use a goog JS namespace again:
Uncaught ReferenceError: $jscomp is not defined
at statsBar (stats_bar.js:13)
at Constructor.eval (d3.cljs:25)
at Constructor.reagent$impl$component$custom_wrapper_$_componentDidMount (component.cljs:189)
...
moving this from lein-figwheel. I think it had the output set to es6 and I probably didn’t do the same in my shadow config
I'm not entirely sure why the $jscomp polyfills are missing though. they should be added
but it isn’t executing until I switch to the screen with the graphs, so that doesn’t make sense to me
{:target :browser
:modules {:main {:entries [amperity.web.dev
amperity.web.prod]}}
:output-dir "resources/public/js/compiled/"
:asset-path "js/compiled/"
:compiler-options {:language-in :es6
:output-feature-set :es6
:devcards true}
:dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
"day8.re_frame.tracing.trace_enabled_QMARK_" true}}
:preloads [day8.re-frame-10x.preload
devtools.preload]
:external-config {:devtools/config {:features-to-install
[:formatters :hints :async]}}}
statsBar is still getting compiled to:
var $jscomp$destructuring$var0 = $jscomp.makeIterator(getRequiredKey(options, "dimensions"));
https://github.com/thheller/shadow-cljs/commit/efd7d443ce7735405e41994543c37cb25189b367
it kinda presumes that the only closure JS files are from the closure library which won't change 😛
Is it possible to access state gathered via compilation (e.g., a macro that writes to an atom) right before the build finishes and the information is (possibly) discarded?
@isak are you talking about during when you have a watch running, or during a release build?
@lilactown this is during a release build
@lilactown I'd like to make a translation function/macro that automatically makes the texts/text-ids available for translation (by upserting them to a database)
Similar to this library for elixir: https://github.com/elixir-gettext/gettext
first knee-jerk hacky way would be to write to a file during macro time and then after compilation, have a script that does the upsert
@lilactown interesting. Do you know what kind of issues may arise? Another way that could work is to walk the AST if shadow provides one in a build hook. ( I think I remember seeing something about this )
mainly during dev time when you’re watching the app, macros happen right after read time so e.g. they’ll get run on every incremental compilation of that file
but also the order in which files get compiled isn’t guaranteed deterministic, so if you depend on ordering you might be in trouble
shadow also doesn’t recompile everything in the dependency graph in one go, so if your dependent namespaces also have side effects that need to be run all at once, you’re in trouble
Ok, I was thinking I'd just make the macro pass-through to a function in development, so it sounds like the file-appending strategy would work
I'd be pretty interested to know of a good solution for i18n / localization in first class cljs. If you figure out how to do it well and can share it, I'd greatly appreciate it
@isak I started some proof of concept regarding i18n a while ago but never had a real need to finish it https://github.com/thheller/cljs-i18n-api
the idea was exactly to collect all strings in the metadata and then extract it later via :build-hooks
@U05224H0W oh nice! I will try to build on this.
there isn't much to build on. the only relevant part is this: https://github.com/thheller/cljs-i18n-api/blob/master/src/cljs/i18n.clj#L55-L56
it is the same basic idea as this https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745
so you'll find the data in (get-in build-state [:compiler-env :cljs.analyzer/namespaces 'the.ns :your/key])
remember to use namespaced keys for your data to avoid interfering with the normal compile data
I realize this is likely not its use-case, but for toy examples it’s convenient to use :dev-http {8000 {:handler
as a cheap way to test out client-server interactions. However, when eval’ing server functions, I’m finding that they aren’t picked up until I “bump” the shadow-cljs.edn
file, causing shadow to restart the server. Is there a better way to reload server changes?
I have a Clojure REPL using cider-connect-sibling-clj
in emacs, would that have the http server in-process? After reloading the ns with my handler in it, subsequent HTTP requests from the cljs app don’t appear to invoke the newly eval’d code.
I’m trying out react native support…seeing this:
Exception in thread "async-dispatch-5" java.lang.RuntimeException: java.lang.Exception: Not supported: class cljs.tagged_literals.JSValue
at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:65)
at cognitect.transit$write.invokeStatic(transit.clj:167)
at cognitect.transit$write.invoke(transit.clj:164)
at shadow.cljs.devtools.server.common$fn__15653$fn__15654.invoke(common.clj:59)
at clojure.core$map$fn__5862$fn__5863.invoke(core.clj:2742)
at clojure.core.async.impl.channels$chan$fn__1714.invoke(channels.clj:300)
at clojure.core.async.impl.channels.ManyToManyChannel.put_BANG_(channels.clj:83)
at clojure.core.async.impl.ioc_macros$put_BANG_.invokeStatic(ioc_macros.clj:992)
at clojure.core.async.impl.ioc_macros$put_BANG_.invoke(ioc_macros.clj:991)
at shadow.cljs.devtools.server.web.api$eval36151$fn__36154$fn__36208$state_machine__6737__auto____36227$fn__36229.invoke(api.clj:82)
and so forth. Seems to happen during the flush stage…UI says:
Compiling ...
Flush: cljs/core.cljs