@borkdude has joined the channel
set the channel description: Cherry CLJS transpiler
set the channel topic: https://github.com/borkdude/cherry
set the channel description: https://github.com/borkdude/cherry
Ns form with imports work
(ns index
(:require ["fs" :as fs]
["url" :refer [fileURLToPath]]))
(prn (subs (fs/readFileSync (fileURLToPath js/import.meta.url) "utf-8")
0 100))
(defn foo [{:keys [a b c]}]
(+ a b c))
(js/console.log (foo {:a 1 :b 2 :c 3}))@mail024 has joined the channel
@mkvlr has joined the channel
π
π
So one thing I'm contemplating: should functions with (defn foo ...) be automatically exported with:
export { foo }
unless they are defined with defn- ? Or should exported functions be explicitly marked with (defn ^:export foo ...)set the channel topic: https://github.com/borkdude/cherry π
how do js bundlers handle this? (this = renaming)
what renaming exactly?
how do they decide what names to keep stable and what to rename?
I think keeping the names is good for now, this probably compresses pretty well with gzip
oh that. I think once you are bundling, you can rename everything
since that's a final file
shouldn't matter right?
@mkvlr My thoughts weren't about renaming, it was about generating exports automatically for every defn, or only when marked as exported
I'll go with automatic for every defn for now
@borkdude whatβs the export for?
isnβt that only for closure?
ES6 modules work with exports: you can't import what isn't exported
ah right
in js thatβs explicit, right?
yes
automatic for public vars sounds like a good start
ok, export now working in version 0.0.0-alpha.17
(ns exports)
(def foo (fn [] "Hello"))
import { foo } from './exports.mjs';
console.log(foo());I think we also need a way to do the default export, to be able to write this (bun) example:
export default {
port: 3000,
fetch(request) {
return new Response("Welcome to Bun!");
},
};
Not sure what syntax would be appropriate for that. Perhaps shadow-cljs already has something for this
Went with (def default ...) :)
In action: https://twitter.com/borkdude/status/1550508930438242304
I think a bun cherry run serve.cljs command would be good, which compiles + also runs
Works now
@gdwarner has joined the channel
Export by default
already done :)
@armed has joined the channel