This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-18
Channels
- # announcements (11)
- # architecture (1)
- # aws (2)
- # beginners (101)
- # calva (3)
- # clj-kondo (2)
- # cljdoc (1)
- # cljs-dev (20)
- # clojure (92)
- # clojure-dev (34)
- # clojure-france (1)
- # clojure-italy (2)
- # clojure-spec (13)
- # clojure-uk (3)
- # clojurescript (28)
- # cursive (7)
- # data-science (58)
- # datomic (18)
- # docs (1)
- # fulcro (11)
- # graphql (3)
- # hoplon (25)
- # klipse (3)
- # leiningen (4)
- # nrepl (3)
- # off-topic (57)
- # pedestal (1)
- # portland-or (1)
- # precept (1)
- # reagent (5)
- # reitit (2)
- # rewrite-clj (4)
- # ring (1)
- # shadow-cljs (97)
- # sql (90)
- # tools-deps (2)
I'm trying to make a chrome extension, there is many moving parts, so i output the extension itself to resources/public/js/extension
and set the output-dir
for the background script in resources/public/js/extension/background
.
Compilation works, then I add the extension to chrome targeting resources/public/js/extension
(where my extension manifest is).
The trouble is that now chrome is looking for the modules with /resources/
as root rather than resources/public/js/extension
So how can i ask shadowcljs (or maybe the clojurescript compiler?) to root the js lookup in resources/public/js/extension` ?
now for hot code reloading ...shadowcljs is trying to open a websocket at
which of course doesn't work, how can i tell it to use my already running server at
?
@carkh its not documented well but shadow-cljs can build chrome-extension directly which fixes all those issues https://github.com/thheller/shadow-cljs/issues/279
looking at the issue, you have browser-action and content-script, is it also possible specify the options-page ?
very nice, i'll try to switch to this new workflow and maybe tell you how it goes if you'd like that
here is one extension that uses this stuff maybe that helps in some way https://github.com/fulcrologic/fulcro-inspect/blob/master/shells/chrome/manifest.edn
https://chrome.google.com/webstore/detail/fulcro-inspect/meeijplnfjcihnhkpanepcaffklobaal
is using eval from the shadow-cljs repl supported?
i'm seeing:
[0:0]~cljs.user=> (eval '(+ 1 2))
Error: cljs.core/*eval* not bound
is there some other setup i need to do
@nickmbailey afaik there is no eval with clojurescript
i see
@nickmbailey eval
in CLJS requires using the self-hosted compiler. shadow-cljs does support building everything you need for that but doesn't run it itself. see https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html
@thheller so i switched to the :chrome-extension target as we discussed. And I hit the repl switching problem. I have several running javascript instances under the single chrome-extension build, and i can only invoke the repl on a per build basis... any workaround i should be aware of ?
mhh that's a problem, no auto-completion in cider when in the wrong repl ... too bad i like that whole build target thingie =(
i don't quite know why but it doesn't ... when in a build's repl that doesn't "link" to the current buffer no auto-complete in cider
eval is the only issue since with multiple runtimes it is not clear how to do that consistently
no big deal i'll go back to the old way which was working fine, in the meantime i got better organisation out of this escapade
too bad i'll be losing the modularisation, maybe just use the chrome-extension target for release
is there a way to dynamically define vars in clojurescript?
i'm using intern in a macro in clojure but thats not available in clojurescript
(was previously playing with eval, hence the earlier question)
well it should be fine to happen at compile time but eval wasn't working so i switched to intern which lets it happen at runtime
so i guess i can switch to self hosted clojurescript
and eval
the super dynamic clojure style Var
creation via actual Var
calls will not work even in self-hosted CLJS since there are no vars at runtime
i'm making a macro that makes builder fns for plumatic/schema map keys so:
(crazy-macro foo {:a Int})
creates a var like foo-a
. the problem is i want it to also support (crazy-macro bar (merge foo {:b Int}))
which means i need the evaluated version of the mapin regular clojure just eval'ing the form works, or using intern to inject the vars at runtime also works
well they are builder functions
it creates vars via defn
heh i don't disagree with that
its a bit of a crazy idea
if you can stomach adding several megabytes of JS to your build I guess self-host is something you can try
yeah i'll probably abandon this for clojurescript for now heh
it seems like when shadow-cljs is compiling a .cljc file and it runs into a reader conditional it picks the ":clj" option
hmm why is that?
right, i'm trying to make the macro do nothing in clojurescript
.cljc
is kinda mind bending when it comes to macros and stuff so I would recommend avoiding it as much as possible
hmm well i'm trying to use reader conditionals around the defmacro call completely
#?(:cljs (defmacro...) :clj (defmacro...)
ok but i should be fine if i just split into clj and cljs files?
the trick commonly used in macros that should emit different code for CLJ or CLJS is checking the &env
hmm i'm using :refer-macros
is that the same?
lets others using the.ns
completely skip worrying about macros and just use them as you would in CLJ
ah i put that in the file where the macro is defined
got it
@thheller that got me up and running, thanks for the help!
and more generally thanks for shadow-cljs heh