Fork me on GitHub

does anyone have any experience exporting npm packages that work in the browser as well?


i apologize if this question is misguided. the manual is a painstaking cliff hanger ( i guess im primarily curious whether a webpack workflow would appropriately handle making a :node-library output browser compatible


Yes it should


Rather, node-library should output a webpack-compatible bundle


right, getting more familiar with it. seems like its working well. using this tool has never stopped being positively delightful


@isak I'm trying to write style in cljs, with runtime insertion by library like cljss or herb. not know how will it work in the end yet.


interesting 馃憤:skin-tone-2:

Karol W贸jcik11:07:32

Does shadow-cljs fully supports macro system?

(ns infrastructure.util
   [ :as macro]
   [promesa.core :as p]))

(defmacro defn-handler
  [name & attrs]
  (let [[aname [fn-args & fn-body]] (macro/name-with-attributes name attrs)
        args-count (count fn-args)
        afn `(fn ~fn-args ~@fn-body)]
    `(def ~aname
       (fn [req1# res1# next1#]
         (-> (p/promise (if (= ~args-count 3)
                          (~afn req1# res1# next1#)
                          (~afn req1# res1#)))
             (p/catch #(next1# %)))))))
I've just created macro which is used to define the express.js handlers.
(defn-handler get-login-status
  [req res] 
  (println req res))
For some reason code works perfectly fine but the shadow-cljs outputs a warning:


I've seen a lot of times like something is undeclared but actually it exists. usually cased by how the namespace is created. is it created by file require or by repl evaluation.

Karol W贸jcik11:07:32

@doglooksgood Ok found one bug. The last warning about undeclared is fixed. So there is one left about "wrong number of args passed".


try a macro expand?

Karol W贸jcik11:07:14

Ok I see why 馃槢


Is there olical/depot or lein-ancient equivalent for shadow-cljs managed projects?


you can use deps.edn or leiningen to manage dependencies, is easy for shadow-cljs to use them. so all the tools are available now.


@doglooksgood yeah, was hoping there is something shadow-cljs specific, thanks


@karol.wojcik that is not how macros work in CLJS. they need to be declared in a CLJ namespace (.clj or .cljc)

Vincent Cantin13:07:32

Hi, does shadow-cljs supports dynamic require() in the JS code? I have problem with this JS code that does not work well (not sure yet how):

const required = require(`../vectors/${name}`);
    vector = required.default || required;

Vincent Cantin13:07:57

It works fine when used from a JS project.


@vincent.cantin no that is not supported. you can do it when building for node by just using js/require directly but it is not supported otherwise

馃憤 4

I鈥檝e been thinking about a way to include and instrument specs that wouldn鈥檛 have production runtime cost


if each ns my-project.thing had a corresponding my-project.thing-spec, we could watch for the creation of those files and add their require to a ns that was included via a preloads-like method at dev-time


I鈥檓 thinking of building this as a standalone tool but could be nice as a shadow-cljs feature too


you could build it as a simple shadow-cljs build hook


hmm interesting. does the build state have information about files on the classpath that aren鈥檛 included in the dependency graph?


@lilactown had you tried #ghostwheel? it has a stub thing that can pretty elide all specs and fdefs in prod, both for Clj and CLJS


(the spec part is coming on the next release, but the alpha of it works fine so far)


I haven鈥檛


does it also elide clojure.spec itself?


atm I see cljs.spec.alpha + cljs.spec.gen.alpha + cljs.spec.test.alpha taking a combined ~100kb


yesterday I was advised to switch my dependency from cider/cider-nrepl "0.21.0" to nrepl "0.6.0" which worked in letting me hook vim into the running nrepl. But I now don't have access to cider and all it gives me, including functionality from other plugins that require cider. The folks at #cider tell me they are very different dependencies but I can't get both the nrepl and the cider-nrepl dependencies in this shadow-cljs to work together. Any advice on how to get Cider working right (outside of emacs, I'm using vim)?


@chase-lambert nrepl and cider-nrepl are 2 different things so you need both


just need to match the proper versions


but that'll break a bunch of stuff is something actually needs to use spec at runtime


otherwise you can always include "extra" stuff during dev via :preloads


I kinda like your idea of automatically include *.thing-spec namespaces for dev builds but instrumentation is tricky enough. automating it entirely and getting that right reliably might be tricky


馃榿 yeah. I was thinking of having it enabled via a config flag like:

:auto-spec true
;; or
:auto-spec {:only #{}}
;; or
:auto-spec {:except #{app.baz-spec}}

;; additional
:auto-spec {:include #{app.specs}}


maybe have a parameter for controlling whether it included libs or not too


depending on how it actually shakes out in practice