This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-25
Channels
- # adventofcode (3)
- # aleph (24)
- # architecture (8)
- # beginners (53)
- # boot (34)
- # cider (7)
- # clara (68)
- # cljs-dev (6)
- # cljsrn (3)
- # clojars (10)
- # clojure (71)
- # clojure-germany (2)
- # clojure-italy (10)
- # clojure-nl (25)
- # clojure-serbia (4)
- # clojure-spec (13)
- # clojure-uk (48)
- # clojurescript (31)
- # core-async (62)
- # cursive (13)
- # datomic (4)
- # duct (76)
- # editors (4)
- # fulcro (2)
- # immutant (1)
- # instaparse (1)
- # jobs (1)
- # lein-figwheel (1)
- # mount (1)
- # off-topic (12)
- # onyx (8)
- # re-frame (10)
- # reagent (84)
- # reitit (2)
- # ring (2)
- # shadow-cljs (159)
- # spacemacs (2)
- # specter (17)
- # sql (14)
- # tools-deps (10)
- # yada (15)
I'm connected to the nrepl in emacs but can't seem to eval anything using js/
. Is this only available during compilation.
@theeternalpulse Sounds like you have a Clj repl and not a CLJS repl.
I usually invoke (shadow.cljs.devtools.api/nrepl-select :my-target)
which drops me in the cljs-repl.
Since cider 17 my figwheel set-up for hot reloading chrome extension content script broke, so this seems like an excellent moment to try https://github.com/thheller/shadow-cljs/issues/279
I must be missing something, I thought maybe it's not the latest version of shadow-cljs but that seems to be the latest
Baruchs-MBP-2% shadow-cljs compile chrome-ext
shadow-cljs - config: /Users/baruchberger/stah/cljsc2/shadow-cljs.edn cli version: 2.3.23 node: v8.9.4
shadow-cljs - starting ...
[:chrome-ext] Compiling ...
Target ":chrome-extension" for build :chrome-ext was not found. The built-in targets are:
- :browser
- :browser-test
- :node-script
- :node-library
- :npm-module
- :karma
- :bootstrap
I've done it twice on projects with figwheel, but what I was doing felt like black magic and the blogs writing about it online also have trouble figuring it out.
Awesome, my experience with shadow-cljs so far has been so streamlined, great work.
I'm giving the same path to source-paths
as in my project.clj with lein, but am getting
The required namespace "cljsc2.cljs.content-script" is not available.
. Any hints?
Maybe you have a content-script.cljs
? shadow-cljs is pretty strict about enforcing _
but the error message for that is still missing (or rather ends up in the wrong place)
{:source-paths ["src/cljsc2/cljs"]
:dependencies [[org.clojure/clojurescript "1.9.946"]
[fulcrologic/fulcro "2.5.2"]
[org.clojure/core.async "0.3.443"]
[com.cognitect/transit-cljs "0.8.243"]
[cljsjs/d3 "4.12.0-0"]]
:builds {:chrome-ext {:target :chrome-extension
:extension-dir "out/chrome-ext"}}}
Now I'm getting namespace react not available but I can try to figure out how to solve that π
[:chrome-ext] Build completed. (257 files, 135 compiled, 0 warnings, 57.26s)
Hooray. Let's see if it runs!
@wilkerlucio @bbss just pushed an update for the chrome-ext stuff, still only on master
though. https://github.com/thheller/shadow-cljs/issues/279#issuecomment-392007641
Well I was still solving issues with dependencies, but I got a succesful print from the extension so yes
Had one issue which I assume is because an earlier loaded file errored.
Uncaught TypeError: cljsc2.cljs.contentscript.core.init_BANG_ is not a function
Did anyone faced Uncaught TypeError: $goog$string$$.format is not a function
?
I thought Closure library is somewhat bulletproof to name munging
To use goog.string.format
you need to require the goog.string
namespace and goog.string.format
namespace,
look at this example : https://github.com/reagent-project/reagent-utils/blob/master/src/reagent/format.cljs#L6
Does it solve it?
I have some JavaScript that I need to manually include, is there an easy way to include some js file? I would include it in the html but the content-script has no access to the window.
@thheller I'm getting `At least one js or css file is required for 'content_scripts[0]'. Could not load manifest.` when loading the extension using the latest push.
@bbss you probably need to remove the :content-scripts
entry from manifest.edn
since that will now be generated from :shadow/outputs
err, well non-compiled JS. I have some horrible unoptimized for loops for running through image data.
And normally I manually include these in a script tag of the page. But since the content-script has limited access to that it's saying those are undefined.
you can just (:require ["./some-script.js" :as x])
and its exports will be available via CLJS
you can put it anywhere on the classpath and include it via "/somewhere/some-script.js"
as well
okay, getting close. Jacking in with cider but now the manifest.json is invalid:
"out/cljs-runtime/cljs.pprint.js", ...],
It did! Thanks @thheller. I have my trusty in IDE cljs eval back, now with new shadow-cljs flavor.
However my screen is now full of build warnings after refreshing. I guess I should use proper reflection instead of the regular . syntax.
I can see the image yes. I think the slack message is just info about them not storing it due to lack of premium
.
is native interop and the compiler sometimes needs a hint to figure out if you are working with a JS object which it shouldn't rename
Got my set-up back + the code is simplified a bunch. It's cool to integrate so naturally with JS, I thought cljs<->JS interop was already decent but shadow-cljs really takes it up a notch.
with my approach before I had to include react and d3 from external sources as cljsjs deps didn't work. Now don't even need them π!

figwheel has a on-js-reload. I think :devtools {:after-load ns/fn}
is the analog. But I get can't find fn cljsc2.cljs.contentscript/on-js-reload
. Funnily enough it also reports that when I remove that from the shadow-cljs.edn and add ^:dev/after-load as function meta.
odd. will check. it might be related due to the weird scoping in content-scripts. it probably tries to look up window.cljsc2....
Well, being able to write a module system that works on so many platforms with such a consistent api is π―
All the exceptions, hidden config options and rules with almost no error reporting of the extension ecosystem... Ugh. So much trouble saved in this approach π
not confident that I covered everything for :chrome-extension
yet so I still consider that a WIP
Yes, I feel lucky googleing for "shadow-cljs chrome extension" this morning and seeing your 7 day your old issue with a proof of concept!
just wondering @thheller: I really like your way of thinking and how to pass configs from index.html... but here's the thing: how to pass different configs read from a config file. I mean: if I have 2 index.html files (one for prod and one for dev) that seems fine. However, whenever I need to add some lines (script, css) to index.html, I need to do it in 2 places. So I'd prefer to be able to have a kind of templating/preprocessing of index.html, so it reads the config from a file. How d'you do that usually?
I have been planning a chrome extension for shadow-cljs for years now so it was about time π
@kurt-o-sys my server-side is always clojure so the html is generated by the server which makes adding dynamic stuff pretty easy
oh, ok...
no static html file there, right π
nice, thx!
that will certainly do!
@thheller this is not a big deal, but is there a reason why shadow.loader
canβt be used immediately when a page loads? one must have it called later (or after a 0ms timeout) otherwise an βUnknown module: β¦β error pops up
i was also looking at the builtin cljs.loader. I actually canβt get it to work at all, it shows a warning about source maps not being found and just prints my callback function to the console
anyone having issues accessing the documentaiton?
@theeternalpulse i am able to refresh https://shadow-cljs.github.io/docs/UsersGuide.html w/o issue
odd, it times out on my work or home laptop. I'm on the west coast of north america.
hmm yeah I kind of torn about supporting this. I could make it work ... BUT the idea is that loading should be triggered by a user event
if you are loading one script which then immediately loads another you should just be loading one combined version
currently a shadow.loader.setup
function call is added to the end of the base module
@mhuebert yeah there are valid arguments for loading modules directly. no doubt about that.
i am figuring out how i will do that now. I donβt think this is going to be an issue at all because i will be resolving this in a callback anyway
it was just the first thing i hit trying to test out modules and was wondering if there was something weird going on
(defn init []
(routing/listen
(fn [{:keys [path] :as location}]
(try-module-load))))
(-> js/document
(.addEventListener "DOMContentLoaded" init))
I do this pretty much always https://code.thheller.com/blog/web/2014/12/20/better-javascript-html-integration.html
ie. embed a <script type="shadow/run" data-fn="my.app/init">["some" "args"]</script>
which basically invokes (my.app/init "some" "args")
when the JS is loaded
@mhuebert just pushed [email protected]
which changes the shadow.loader
init so it should be immediately available
I'm getting this error when trying to eval the code above:
utils.async_fetch._GT__BANG__BANG_.call(null,c,"hello");
^
TypeError: Cannot read property 'call' of undefined
does >!
?
ah, so I can't follow [this walkthrough](https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj)
is there one for cljs.core.async?
btw, Hi @thheller
Alrighty! I think I'm finally all set up with SHADOW BABY!
just had to get used to the new error messages π