This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-02
Channels
- # announcements (26)
- # architecture (29)
- # babashka (8)
- # beginners (91)
- # calva (70)
- # cider (7)
- # circleci (2)
- # cljs-dev (1)
- # clojure (79)
- # clojure-australia (2)
- # clojure-dev (3)
- # clojure-europe (40)
- # clojure-italy (2)
- # clojure-losangeles (4)
- # clojure-nl (4)
- # clojure-uk (4)
- # clojurescript (34)
- # cursive (13)
- # datomic (16)
- # defnpodcast (2)
- # emacs (11)
- # events (1)
- # fulcro (13)
- # graalvm (17)
- # gratitude (3)
- # instaparse (10)
- # introduce-yourself (2)
- # jobs (1)
- # jobs-discuss (5)
- # juxt (3)
- # kaocha (5)
- # meander (5)
- # membrane (2)
- # nextjournal (43)
- # off-topic (42)
- # pathom (52)
- # pedestal (8)
- # portal (3)
- # rdf (2)
- # re-frame (10)
- # reveal (21)
- # shadow-cljs (56)
- # slack-help (7)
- # vim (33)
- # xtdb (43)
Hi @thheller, can you tell me where I’m supposed to be setting closure-defines option at?
in the build config? https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines
Here it’s not wrapped inside compiler-options, is that not necessary?
can be directly in the build config or :compiler-options {:closure-defines ...}
. both work
I followed this - https://github.com/thheller/shadow-cljs/issues/217, and my config looks similar to it
But CLOSURE_DEFINES is still coming up as undefined
CLOSURE_DEFINES
should be of no concern to you. if you are trying to use it you are doing something incorrectly.
browser
oh, I don’t
But if I’m setting something from the Closure library, I don’t need to explicitly define that right?
:closure-defines {goog.json.USE_NATIVE_JSON true}
Weird, I’ve added it inside builds and even in every individual profile, still no luck
should be in {:builds {:build-id {:target :browser :closure-defines {goog.json.USE_NATIVE_JSON true}}}
in shadow-cljs.edn
Yep, just checked, I’m able to find it there
Just to confirm, I’m checking for CLOSURE_DEFINES in the browser, if it’s undefined then that means it was not configured properly right?
again CLOSURE_DEFINES
is of no concern. it is an implementation detail. forget it exists.
it is running in an actual browser. directly without any other build tools post processing it in any way? meaning you are loading the output actually produced by shadow-cljs, not something else.
The way that it’s configured is using lein with shadow-cljs
I’m actually very new to Clojure and especially the tooling so my apologies if that’s not what you were asking for
I’m building an uberjar with lein uberjar-app
:uberjar-app {:prep-tasks [["shadow" "release" "app"]
"compile"]}
“app” is the build-id
exactly. I assume that is a standard :advanced
build. this will be optimized and no traces of the CLOSURE_DEFINES will be left. so you definitely cannot look that up there
but point is looking it up manually via CLOSURE_DEFINES
in release
builds is not possible
oh okay
I was able to see it in dev so I figured the same would be possible in release as well
okay got it, but yea I’m setting it in release as well
the whole purpose is to prevent closure compiler from using eval methods
cause I have a content-security-policy configured to block all eval methods
I found out online that this is the flag that actually prevents it from using eval
it should already use JSON.parse
if thats available? so it won't use eval if that is available?
Hmm doesnt seem to be the case, CSP is still flagging methods for using eval in the compiled script
you can compile shadow release app --debug
. that'll give you source maps and use pseudo names
oh awesome, i’ll try that
been banging my head at this for hours, thank you for some direction