This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-24
Channels
- # adventofcode (2)
- # anglican (1)
- # announcements (4)
- # aws (2)
- # babashka (28)
- # beginners (18)
- # brompton (3)
- # calva (22)
- # clj-kondo (2)
- # cljdoc (29)
- # clojure (41)
- # clojure-europe (28)
- # clojure-gamedev (14)
- # clojure-nl (2)
- # clojure-spec (2)
- # clojure-sweden (1)
- # clojure-uk (6)
- # clojurescript (53)
- # css (3)
- # cursive (6)
- # duct (3)
- # emacs (5)
- # fulcro (29)
- # introduce-yourself (1)
- # liberator (5)
- # lsp (1)
- # malli (11)
- # meander (4)
- # nbb (11)
- # off-topic (17)
- # pathom (2)
- # polylith (8)
- # practicalli (1)
- # react (6)
- # reagent (11)
- # releases (2)
- # rewrite-clj (11)
- # shadow-cljs (59)
- # tools-deps (21)
- # vim (11)
I have a little dilemma (again) regarding ecmascript modules. E.g. the term-size
package now only offers an ESM module
while other libraries only offer a CommonJS module, this is what nbb currently defaults to
but it's probably not a good idea to mix and match those. And the ESM stuff is a superset of the CommonJS stuff: dynamic import also supports loading those
But then it would make scripts look like:
$ cat test-scripts/esm-test/script.cljs
(ns esm-test.script
(:require ["path$default" :as path]
["term-size$default" :as term-size]))
(prn (path/resolve "."))
(prn (term-size))
$ node out/nbb_main.js test-scripts/esm-test/script.cljs
"/Users/borkdude/Dropbox/dev/clojure/nbb"
#js {:columns 209, :rows 52}
the $default
thing is a bit of an ugliness in my taste, but perhaps it's better to just support this style going forward so all libs can be required in one style
so, for example this works now (`zx` is an ESM module):
(ns script
(:require ["csv-parse/lib/sync$default" :as csv-parse]
["fs" :as fs]
["shelljs$default" :as sh]
["zx$fs" :as zxfs]
[nbb.core :refer [*file*]]))
(println (count (str (fs/readFileSync "script.cljs"))))
(prn (sh/ls "."))
(prn (csv-parse "foo,bar"))
(prn (zxfs/existsSync *file*))