This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-20
Channels
- # 100-days-of-code (2)
- # aleph (53)
- # architecture (2)
- # aws (3)
- # beginners (230)
- # boot (15)
- # calva (3)
- # cider (19)
- # cljs-dev (1)
- # clojure (139)
- # clojure-conj (3)
- # clojure-italy (47)
- # clojure-nl (19)
- # clojure-spec (26)
- # clojure-uk (98)
- # clojurescript (152)
- # clojutre (4)
- # core-async (22)
- # cursive (5)
- # datomic (48)
- # emacs (11)
- # events (1)
- # figwheel-main (219)
- # fulcro (15)
- # instaparse (3)
- # jobs (4)
- # jobs-rus (1)
- # leiningen (30)
- # luminus (8)
- # off-topic (67)
- # onyx (5)
- # pedestal (16)
- # re-frame (1)
- # reagent (4)
- # reitit (31)
- # ring (8)
- # ring-swagger (3)
- # shadow-cljs (115)
- # specter (4)
- # videos (1)
- # vim (20)
- # yada (15)
@dfcarpenter Cursive has that built-in but there is also https://github.com/kkinnear/zprint
is there a way to exclude an optional npm dependency that is pulled in via a library? https://github.com/dbushell/Pikaday/issues/718
pikaday supposedly uses moment optionally but it gets pulled in regardless, there's a hack for webpack but how would I do this in shadow-cljs?
my code now compiles fine in dev mode, but when i run shadow-cljs run shadow.cljs.build-report app build-report.html
i get a spec error when trying to compile specter
how do you like specter? I never looked into it much but recently I feel like I've been doing a lot more nested stuff where it supposedly helps?
I think it is awesome, though I don’t like how big it is, but in reality, I’m writing a very heavyweight app so it doesn’t really matter
for the front end, I do the standard single-atom state object and have all of my mutators in one place sort of like redux reducers
something like this is where it really shines:
(multi-transform
[ATOM (multi-path
[:notebook-order (terminal-val notebook-order)]
[:notebooks (terminal #(merge-with into % notebooks))])]
root)
This replaces one key and merges in with another in a single mutationif you have a lot of this kind of stuff it becomes pretty easy to read and is very concise
code like this .. a nested map where I want to remove stuff by some nested key deep down
ideally I'd want to remove some values but also return the values that were removed besides the updated value
right i’m not 100% sure i follow this code but its the kind of thing that specter is good at
I do that by-id transform quite a bit so i have a helper:
(defn by-id [id] (fn [elt] (= (:id elt) id)))
(setval [ATOM :uploads ALL (by-id (:id upload))] upload root)
yeah I guess I'll look into it some more. heard enough interesting things about it by now so it seems to be useful
it is a bit complicated, i’ll say, but in my opinion it is harder to write than to read. also nathan is quite responsive in #specter. supposedly it is super fast, thought that doesn’t matter to me so much
i’ve chatted with nathan about getting the code size down. he said it is definitely possible to pull in less of the library, but he doesn’t do a lot of cljs so hasn’t messed with it. it adds 188k of unzipped code
I’m trying to autorun tests in cljs files. I’ve used the config in the docs
{...
:builds
{:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-spec$"
:autorun true}}}
shadow-cljs compile test
The tests run fine:
shadow-cljs - connected to server
[:test] Compiling ...
========= Running Tests =======================
FAIL in (a-failing-test) (cljs-runtime/cljs/test.cljs:476:9)
expected: (= 1 2)
actual: (not (= 1 2))
Testing test.classify-test
FAIL in (a-failing-test) (cljs-runtime/cljs/test.cljs:476:9)
expected: (= 1 2)
actual: (not (= 1 2))
Ran 2 tests containing 2 assertions.
1 failures, 0 errors.
===============================================
[:test] Build completed. (27 files, 1 compiled, 0 warnings, 0.99s)
But then the tests quit and don’t watch for changes. What does autorun do? Is there a way to run the tests when either the tests change or the functions they test change? ThanksYep - that is working. Thank you
so I am using bunyan
in shadow-cljs
and they have a logger object that has a .child
method
what would be that quickest way to provide or infer this extern so that it does not get renamed?
I see shadow-cljs check
complains about it, which is good
can I just use ^js
?
ah no I can't I am in a macro ...
ok using this for now:
{:optimizations :advanced
:variable-renaming :off
:property-renaming :off
:source-map true}
no time for fiddling 😄@richiardiandrea you can use it in a macro just fine. just need to watch how you create the symbol
@thheller isn't ^js
a reader macro? maybe I am mistaken
uhm ok, it did not work...
I do:
(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(. ^js (deref laputa.event-store.logging/parent-logger)
(~'child (cljs.core/js-obj
:namespace (laputa.event-store.logging/self-ns-name)
:level (if ^boolean goog.DEBUG "debug" "info")))))
that is maybe what is not working
(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(.child ^js (deref laputa.event-store.logging/parent-logger)
(cljs.core/js-obj
:namespace (laputa.event-store.logging/self-ns-name)
:level (if ^boolean goog.DEBUG "debug" "info"))))
I was trying (let [the-sym (with-meta 'child {:tag 'js})]...
(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(laputa.event-store.logging/get-child-logger
(cljs.core/js-obj
:namespace (laputa.event-store.logging/self-ns-name)
:level (if ^boolean goog.DEBUG "debug" "info"))))
right 😄
let me see and thanks 😄 did not know about that trick above
(defmacro child-logger
"Create a child logger for the current namespace."
[]
`(laputa.event-store.logging/get-child-logger
(laputa.event-store.logging/self-ns-name)
(if ^boolean goog.DEBUG "debug" "info")))
@thheller another question, how would you go about not renaming env vars? e.g.: process.env.PGDATABASE
oh ok, I was using process.env.PGDATABASE
which works at runtime but it is obviously odd...forgot the js/
with check
yes, I just checked
File: /home/arichiardi/git/laputa/event-store/src/laputa/event_store/db/config.cljs:31:19
Property PGDATABASE never defined on process.env
ok will open an issue
still getting the warnings with check
after js/
was added
Ok well, might be something here ;)
@thheller do you use a monorepo? if yes do you have a shadow-cljs
server started in the monorepo root?
(is it possible?)
not sure I understand the question. define a monorepo? I have one repo per project? is that a monorepo?
yep so I have this:
├── cljs-template
├── commit-event-fn
├── continuous-delivery
├── dashboard
├── lerna.json
├── metrics-fn
├── package.json
├── query-events-fn
├── README.md
├── registry-fn
├── scrutinizer-fn
each folder has a shadow-cljs
file, I was wondering if I could share the jvmif you look at the shadow-cljs repo there are quite a few builds now that actually do stuff and aren't just for testing
I could probably have a shadow.edn in the root containing all the builds for the subrepos..
oh ok yeah
will have a look
https://github.com/thheller/shadow-cljs/tree/master/packages three of those are actual npm packages
yep I see, we have a different folder layout
that's ok, just wondering, would've been cool useful
I never saw a reason to organize the code that way since it just gets annoyingly hard to share code
yeah we moved away from that to make sure we isolate lambda development...
trying to make sure what we share goes in a lib but has some friction so that it does not become a kitchen sink
we already use namespaces to organize code so for CLJS I see no reason they can't all be on the same source-path
I know I know how you feel about that and that's ok in single project, everything is on the classpath, but it was getting messy...
so the team decided to split
was not even my own decision per se
still very happy with shadow-cljs
, I could potentially include everyting in a big deps.edn
+ shadow-cljs.edn
at some point...will see