This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-10
Channels
- # adventofcode (3)
- # aws (2)
- # beginners (85)
- # boot (8)
- # boot-dev (4)
- # cider (36)
- # clara (3)
- # cljs-dev (87)
- # cljsrn (3)
- # clojure (87)
- # clojure-austin (12)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-dusseldorf (5)
- # clojure-estonia (5)
- # clojure-greece (4)
- # clojure-italy (3)
- # clojure-spec (17)
- # clojure-uk (55)
- # clojurescript (70)
- # core-logic (2)
- # cursive (6)
- # data-science (18)
- # datomic (13)
- # emacs (34)
- # fulcro (347)
- # graphql (12)
- # hoplon (6)
- # jobs (3)
- # jobs-discuss (43)
- # juxt (2)
- # keechma (31)
- # leiningen (29)
- # lumo (2)
- # midje (2)
- # off-topic (118)
- # om-next (4)
- # onyx (39)
- # pedestal (6)
- # re-frame (85)
- # reagent (21)
- # remote-jobs (3)
- # ring (5)
- # rum (2)
- # shadow-cljs (126)
- # spacemacs (1)
- # sql (6)
Hi, I am trying to add d3
as a deps in a shadow-cljs
project. I've found that in shadow-cljs
demo/browser.cljs
, it uses (:require ["d3" :as d3])
to include d3
but the "d3"
in shadow-cljs.edn
was commented out. I am wondering how the d3
in demo/browser.cljs
can work. Should I add d3
in the package.json
and (:require ["d3" :as d3])
to make d3 work in my project?
@thheller I'm guessing you are aware, but I've just seen that clojurescript's :foreign-libs thing does seem to have support for the kind of preprocess step we were talking about yesterday: https://clojurescript.org/guides/javascript-modules#babel-transforms. I don't think that changes anything w.r.t. shadow-cljs, but might offer some inspiration
@alex340 yes I’m aware. I suggested the :preprocess a.qualified/symbol
syntax. so far I have gotten away without any configuration for this and babel
in theory could automatically be applied if there was a .babelrc
present
@cmal you might want to consider using the separate d3-*
packages instead of the d3
meta package. eg. (:require ["d3-color" :as d3-color])
instead of accessing the d3.color
property. avoids always importing everything.
@thheller Does the "d3-color"
here means I should add a d3-color
to my package.json
in the same directory of shadow-cljs.edn
?
but you can also skip the d3 install there and just install what you need in package.json
@thheller :shadow.build/mode
showed to me :dev despite useing whitespace optimization. As for background scripts, it takes an array so I see it as one way to serve the depending js files, maybe there's another way to do it, but for example adblockplus uses 7 js files in background scripts. If it's only for development then it's probably ok, the user needs to http regex match if they want it to run on all or only specific addresses.
ok, so my test is really, is this a single file output compilation or does the cljs-runtime
dir get bundled too.
I don’t know if background scripts are allowed to importScripts
or something to load other files
why did you mess with :module-hash-names
in the example? that doesn’t seem useful for chrome exts? the hash names are meant to that you can http cache the files forever since new versions will have different names
good question, I never found documentation so far that it's part of js dev practices. Reloading an extension is either a button or you can dowload an extension to reload all extensions.
if the extension is allowed to connect to the websocket the CLJS hot reload should just work
@thheller https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998#file-chrome_extension-clj-L63-L64 isn't this how :module-hash-names
should be, don't think you copied all the code above 🙂 ?
you can write it by hand and if you only generate one file you don’t need to modify the manifest at all
@thheller yes that's right, the only reason I wanted to generate it was because I didn't want to type in all the files. If it's one file, then there's no reason to generate it.
don't I lose some optimization of haveing it in one file, say I only change one namespace, then all the data is compiled?
by default there are some checks in place to avoid some IO but technically you could just always write
I pretty much always follow this pattern https://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs
FWIW (defonce app-container (js/document.getElementById "app"))
and then (r/render [..] app-container)
is probably the safer thing to do
no statically serving the file did not help either. Now I get no error but the page is blank...
I've updated the script https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998 runs smoothly, works well when output-dir is set to target and the output-to single file to the directory I'm working on
:output-dir "target/js"
:output-to "js/main.js"
Tried adding the autoreload
:devtools {:autoload true}
and starting the repl
shadow-cljs cljs-repl :my-id
opening the extension background page I get
main.js:90082 WebSocket connection to '' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
DEVTOOLS: disconnected!
must be my config, read that websockets are fine in crx's.@hlolli by default it uses js/document.location.hostname
to connect to which is incorrect here
@thheller if I remember correctly shadow already includes https://github.com/binaryage/cljs-devtools, but I’m not seeing formatted logging. Is my memory wrong?
no it doesn’t include cljs-devtools
but it does have its own little console utilities which do basic formatting
Oh ok, nvm then. I’ll just add it separately
Thanks
yeah just add it to the classpath and :devtools {:preloads [devtools.preload]}
… way too much devtools in that line but it works 😉
Hahah yeah
Yeah that’d be pretty cool
I almost never continue a project without it
[email protected]
should automatically include it if its on the classpath
I’ve added this to a new Devtools page on the wiki: https://github.com/thheller/shadow-cljs/wiki/Devtools
thanks! @U0CKQ19AQ started writing a user guide yesterday. I like that format a lot more than the wiki so I’ll be moving all documentation over to that. See https://shadow-cljs.github.io/docs/UsersGuide.html
PRs very welcome. I’ll work on this primarily for a while until I’m not ashamed of the docs anymore 😉
Added a quick PR to document this update
Might want to hold off on PRs for a few days. I work pretty rapidly on docs, and it would be distracting and confusing. I'd more appreciate additions to the wiki with issues opened on the repo pointing to that content. That way I can pull it in when it makes sense.
unless it is just typo/clarification stuff...those can be fine. But I may re-org pretty dramatically this early
Yep, no problem. Feel free to merge or cancel if it feels like too big a change.
Awesome! Thanks @thheller
I’ve added this to a new Devtools page on the wiki: https://github.com/thheller/shadow-cljs/wiki/Devtools