Skip to content

Commit

Permalink
Add all core functions
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jul 21, 2022
1 parent a8780d1 commit 8641619
Show file tree
Hide file tree
Showing 8 changed files with 477 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ lib
report.html
test/scratch.js
dist
.work
29 changes: 11 additions & 18 deletions bb/tasks.clj
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
(ns tasks
(:require [babashka.process :refer [shell]]
[clojure.edn :as edn]
[clojure.java.io :as io]))

(def core-config )

(def core-vars (:vars core-config))

(def core->js (:to-js core-config))


(defn shadow-extra-config []
(:require
[babashka.fs :as fs]
[babashka.process :refer [shell]]
[clojure.edn :as edn]
[clojure.java.io :as io]))
(defn shadow-extra-config
[]
(let [core-config (edn/read-string (slurp (io/resource "cherry/cljs.core.edn")))
vars (:vars core-config)
to-js (:to-js core-config)
_ (prn to-js)
ks (map #(get to-js % %) vars)
ks (map #(symbol (munge %)) vars)
vs (map #(symbol "cljs.core" (str %)) vars)
core-map (zipmap ks vs)]
(prn core-map)
{:modules
{:cljs_core {:exports core-map}}}))

(defn build-cherry-npm-package []
(shell "npx shadow-cljs release cherry --config-merge"
(shadow-extra-config)))
(fs/create-dirs ".work")
(spit ".work/config-merge.edn" (shadow-extra-config))
(shell "npx shadow-cljs --config-merge .work/config-merge.edn release cherry"))
2 changes: 2 additions & 0 deletions corpus/core_vars.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
(dissoc x :foo))

(log (str (foo {:foo 1 :bar 2})))

(prn (reverse (map (fn [x] (inc x)) [1 2 3])))
9 changes: 7 additions & 2 deletions corpus/core_vars.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toJs, first, dissoc, get, vector, keyword, str, arrayMap } from 'cherry-cljs/cljs.core.js'
import { first, dissoc, map, reverse, get, prn, vector, keyword, str, clj__GT_js, arrayMap } from 'cherry-cljs/cljs.core.js'

const js_map = toJs(arrayMap(keyword("foo"), keyword("bar")));
const js_map = clj__GT_js(arrayMap(keyword("foo"), keyword("bar")));
console.log(js_map);
const clj_map = arrayMap(keyword("foo/bar"), (1 + 2 + 3));
console.log(get(clj_map, keyword("foo/bar")));
Expand All @@ -13,3 +13,8 @@ return (function () {
})();
};
log(str(foo(arrayMap(keyword("foo"), 1, keyword("bar"), 2))));
prn(reverse(map(function (x) {
return (function () {
return (x + 1);
})();
}, vector(1, 2, 3))));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "module",
"name": "cherry-cljs",
"sideEffects": false,
"version": "0.0.0",
"version": "0.0.0-alpha.8",
"files": [
"cljs.core.js",
"lib/cljs_core.js"
Expand Down
Loading

0 comments on commit 8641619

Please sign in to comment.