This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-17
Channels
- # ai (115)
- # announcements (8)
- # babashka (26)
- # beginners (7)
- # biff (8)
- # calva (1)
- # cider (10)
- # clerk (2)
- # clj-together (11)
- # clojure (26)
- # clojure-boston (1)
- # clojure-denmark (3)
- # clojure-europe (23)
- # clojure-nl (1)
- # clojure-norway (33)
- # clojure-uk (3)
- # clojurescript (14)
- # conjure (3)
- # cursive (65)
- # emacs (10)
- # events (18)
- # exercism (6)
- # honeysql (14)
- # hyperfiddle (11)
- # kaocha (6)
- # nbb (17)
- # off-topic (58)
- # pathom (5)
- # reagent (28)
- # reitit (1)
- # releases (1)
- # sci (3)
- # shadow-cljs (22)
- # xtdb (29)
Would it be possible to download CLJS dependencies in nbb without needing babashka installed? (One of the reasons I use nbb
is precisely so I don’t have to build or use bb
)
Currently not unless you clone them locally yourself and add them to the classpath yourself
Is there a way to instruct babashka where clojure is installed? For some reason it wants to randomly download things into ~/.deps.clj
, but doesn’t clojure itself already come with deps.edn? In fact I already have access to a clj
command on my PATH and I can use -Sdeps
and everything else. Not sure why bb
is unable to find it
Is it possible to publish nbb scripts to npm if they have a CLJS dependency? I assume the JAR will have to be bundled somehow into what gets published
@U0479UCF48H This might help: https://github.com/babashka/nbb/tree/main/doc/bundle You can create a single file from your CLJS files and then publish that to npm
And here are some docs for publishing to npm: https://github.com/babashka/nbb/tree/main/doc/publish
Very nice. One more question: is nbb capable of importing JS files that are Google Closure modules? The CLJS library I’m dealing with has a JS file beginning with goog.provide("some.namespace");
it exists in some/namespace.js
but (require '[some.namespace])
fails in nbb.
If you’d like to experiment, I am using {lilactown/helix {:mvn/version "0.1.10"}}
. Running (require '[helix.core :as hx])
fails with Could not find namespace: helix.impl.classes
, but there is a helix/impl/classes.js
file and it begins with goog.provide("helix.impl.classes");
hmm this doesn't work, but maybe we can mock this with:
(j/assoc-in! js/globalThis [:goog :provide] (fn [s] (j/assoc-in! js/globalThis (vec (.split s ".")) #js {}))
or soYeah, it looks like importing closure modules won’t be possible; I’ll use reagent I guess.
well, I am very stubborn … I have made a partial port of Helix to nbb. Not everything is supported, just enough for building TUIs with Ink. I stripped out class components, too, since people can simply import react-error-boundary
. I have tenatively called this port “twirl”
Here’s a quick demo in case you’re wondering how it looks.
(ns demo.core
(:require ["ink" :as ink]
[twirl :refer [$ defnc]]
[twirl.hooks :as hooks]))
(defnc counter []
(let [[counter set-counter] (hooks/use-state 0)]
(hooks/use-effect :once
(let [timer (js/setInterval #(set-counter inc) 1000)]
(fn unmount []
(js/clearInterval timer))))
($ ink/Text {:color "green"}
(str counter " test passed"))))
(ink/render ($ counter))
Wow bundle
is amazing! I didn't know about this, thanks. 🙏