This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-04
Channels
- # announcements (30)
- # aws (7)
- # babashka (7)
- # beginners (64)
- # calva (39)
- # cherry (17)
- # cider (1)
- # clj-on-windows (6)
- # clojure (30)
- # clojure-austin (12)
- # clojure-europe (25)
- # clojure-nl (2)
- # clojure-norway (23)
- # clojure-spec (23)
- # clojure-uk (6)
- # clojurescript (20)
- # cursive (18)
- # datahike (3)
- # datalevin (12)
- # datomic (9)
- # etaoin (5)
- # graalvm (45)
- # instaparse (2)
- # interceptors (11)
- # kaocha (1)
- # lsp (102)
- # meander (6)
- # nbb (16)
- # off-topic (30)
- # pathom (83)
- # pedestal (6)
- # portal (5)
- # re-frame (12)
- # reitit (5)
- # rewrite-clj (10)
- # scittle (35)
- # shadow-cljs (49)
- # spacemacs (10)
- # vim (14)
Hello 👋 I’m trying to use react-pdf-viewer w/ pdfjs and seeing this compilation error:
Failed to inspect file
<elided>/node_modules/pdfjs-dist/build/pdf.js
it was required from
<elided>/node_modules/@react-pdf-viewer/core/lib/cjs/core.min.js
Errors encountered while trying to parse file
<elided>/node_modules/pdfjs-dist/build/pdf.js
{:line 2118, :column 9, :message "Semi-colon expected"}
Might just be an actual problem with this version of pdfjs, but posting here in case it has something to do with compilation iteself
--- has anyone seen this type of error during compilation?
Thank you 🙏@prnc unfortunately this is an error in the closure compiler. usually code it doesn't support. nothing I can do on the shadow-cljs side about it. only option is using a different bundler for JS as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external
No worries @thheller — I was afraid that was the case, thank you so much for confirming!
Hi all: I'm trying to figure out how to use a custom middleware list with a shadow-cljs nREPL (cljs). The default cider stack contains one piece of middleware, wrap-out
that redirects all std out to the cider REPL, which I personally find a bit of a pain to work with.
Normally I would just remove it from the stack, but I haven't been able to figure out how to provide shadow with a custom middleware list. I've tried both ~/.nrepl/nrepl.edn
and using the .shadow-cljs.edn
{:nrepl {:middleware ...}
option, which the docs say are supported, but neither seems to have the desired effect. In fact, the shadow nREPL server does not seem to want to recognize "ls-middleware"
operation so I can verify what middleware is being loaded:
({:id "1a43aa3c-2865-4513-9a2b-51c1166e2e40",
:op "ls-middleware",
:session "8dc66073-fd36-4cf1-a6b0-936d59c1993b",
:status ["done" "unknown-op" "error"]})
When I start up the same version of nREPL server and Cider outside of shadow, the above :op
return the full list of middleware being loaded by the server, as expected.
Am I doing something wrong? Any suggestions where I can go from here?I’m about to get on a plane so can’t find it but there’s a way to not invoke that middle ware
You don’t need to exclude it from your middleware stack. Just not call the op “subscribe-out”
Ok, much appreciated! I'm myself just about to get in a car, but that sounds like a promising alternative to the workflow I've been using all this time (custom middleware list with just that one missing). I'll give it a shot next week.
:nrepl {:middleware ...}
should be fine but it is only additive. it'll not override or remove defaults
double checking my understanding here.. I am depending on an NPM library called “mathlive”. is it therefore not possible to use mathlive
in my clojure namespace paths?
I have a namespace mathlive.core
, which compiles great. But if I do this:
(ns mathlive.core
(:require ["mathlive" :as ml]))
(defn Mathfield [!state] [:div "testing"])
then I see this error:
TypeError: Cannot set properties of undefined (setting 'Mathfield')
triggered from this compiled js:
mathlive.core.Mathfield = (function mathlive$core$Mathfield(_BANG_state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1057191632),"test"], null);
});
of course this restriction would make sense, for some reason I thought when this came up for the “mathbox” library I had decided that I WAS able to use namespaces like mathbox.core etcit doesn’t seem to be a problem for a few of my namespaces to be mathlive.something
; just this one, maybe since it is the first namespace to require the js “mathlive” dependency?
Mathlive.Core is null, very weird. I will see if I can repro it with a smaller build
does this lib maybe forcefully export a global mathlive
JS variable? that would indeed clash with and destroy the CLJS namespace
digging a bit, that makes sense
https://github.com/arnog/mathlive/blob/ca7ed3001a14507961f12e8757254995c1931e7f/src/mathlive.ts#L102 this lives all around the codebase, he’s got it in a few spots
@thheller probably out of luck here, yeah?
should I be calling the library something like mathlive-cljs to fix this?
Just released my first production cljs frontend app https://www.crunchydata.com/pricing/calculator
That’s great! The calculator part or the whole site?
Will be interested in hearing your thoughts on it if you ever have time, not sure the size of it but with larger more complex cljs apps I’m starting to struggle a little. Of course never done anything big in TS so maybe the browser is just a tough environment
Keeping the code base understandable and maintainable with runtime sprawl
webworkers, service workers, web workers and service workers but user disallows cookies, no web workers or service workers allowed but still need to run with gracefully degraded performance, etc.
not to mention cloud functions, nodejs, blah blah
and of course I’m trying to be a good dev and not write if statements everywhere, trying to write exstensible data types underlying a core layer of business logic that should remain essentially unchanged regardless of runtime
And I never thought I’d ever say this but lack of inheritance is kind of becoming a problem
And I know the answer is “just use maps”… and that’s how it started of course
but the browser is too permissive, it doesn’t crash, errors just start to accumulate and it’s not obvious at first
nils
being both logically false AND the default return value of a function that crashes AND a missing key is kind of a rough overlap
Anyway all these things have answers and those answers are called macros but as a result my code base is starting to look less and less like recognizable earthling cljs and more Martian
Shadow cljs has been pretty clutch tho, thanks @thheller , super grateful
I think it comes down to two key things: Either coming up with an architecture that can be adapted to as many use cases as possible, where you can model most if not all problems in a similar way. My goto is using event-streams with Bacon.js and reagent atoms. Alternatively, it's ok to start out rough and refine as you go along. The first version of the price calc I had implemented almost all in one file, then when I got inspiration for a better design and architecture that fit my needs, I refactored. Because I started loose, I also had early progress to show stakeholders.
nil
doesn't have to be the missing key return. When I need distinction I use (get a-map :my-key ::not-found)
or (:my-key a-map ::not-found)
that’s true, but ::not-found
is logically true except by convention. And then you’ve started on the slippery slope. Because then you need a class of predicates that treats ::not-found
as false. And the long tail of that is a cascade of issues. However I do think that what you said about showing early rapid progress to stakeholders is incredibly important
I’ve found the sweet spot for cljs in one-off internal tools that need to be made quickly and high quality but don’t need a lot of coordination to make
I haven't ran into that with my medium sized internal prototypes or the side projects I've taken on. The only time I find myself having to use conditionals is when I am trying to express behavioral optionality, have not had to use them for safety
https://gist.github.com/eccentric-j/6c19f2b57513c90ddde4b37c992746d1 here's a sample of the app
It does the calculations reactively and if something results in nil it doesn't break anything
Awesome! Thank you for sharing. And great work. I think cljs is very challenging and a lot of respect for anyone that does it commercially
It can be, it did take me about 3 attempts to learn clojure before it clicked, but once I spent a year learning functional programming in js, clojure really clicked and have been really enjoying it ever since but I think it depends on the team. For example, the backend team wrote an article on why they chose Ruby in 2022. It's because it was familiar, they liked the repl experience for dealing with production issues, the team had experience with it, and they were interested in learning how to make the most of it warts and all. https://www.crunchydata.com/blog/crunchy-bridges-ruby-backend-sorbet-tapioca-and-parlour-generated-type-stubs