This repository was archived by the owner on Jan 2, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +46
-15
lines changed Expand file tree Collapse file tree 7 files changed +46
-15
lines changed Original file line number Diff line number Diff line change 1
- {:paths [" src" ]
1
+ {:paths [" src" " resources " ]
2
2
:tasks {test {:doc " Run tests"
3
3
:task (clojure " -M:cljs:test" )}}}
Original file line number Diff line number Diff line change
1
+ (ns no-core-vars )
2
+
3
+ ; ; The expectation is that when bundling this, it will only be a couple of bytes.
4
+
5
+ (defn foo []
6
+ [])
7
+
8
+ (js/console.log (str (foo )))
Original file line number Diff line number Diff line change
1
+ import { vector , str } from 'cherry-cljs/cljs.core.js'
2
+
3
+ function foo ( ) {
4
+ return ( function ( ) {
5
+ return vector ( ) ;
6
+ } ) ( ) ;
7
+ } ;
8
+ console . log ( str ( foo ( ) ) ) ;
Original file line number Diff line number Diff line change 1
- {:deps {borkdude/edamame {:mvn/version " 1.0.0" }}
1
+ {:paths [" src" " resources" ]
2
+ :deps {borkdude/edamame {:mvn/version " 1.0.0" }
3
+ babashka/process {:mvn/version " 0.1.7" }
4
+ }
2
5
:aliases
3
6
{:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version " 2.19.6" }}}
4
7
:test ; ; added by neil
Original file line number Diff line number Diff line change
1
+ {:vars #{map assoc str keyword symbol
2
+ dissoc conj vector clj->js js->clj get
3
+ hash-map array-map first rest next nth seq}
4
+ :to-js {clj->js toJs
5
+ js->cljs toCljs
6
+ hash-map hashMap
7
+ array-map arrayMap}}
Original file line number Diff line number Diff line change 27
27
(ns #^{:author " Allen Rohner"
28
28
:doc " A library for generating javascript from Clojure." }
29
29
cherry.transpiler
30
- (:require [clojure.string :as str]
31
- [com.reasonr.string :as rstr]
32
- [edamame.core :as e])
33
- (:use clojure.walk))
30
+ (:require
31
+ [clojure.edn :as edn]
32
+ [clojure.java.io :as io]
33
+ [clojure.string :as str]
34
+ [clojure.walk :as walk]
35
+ [com.reasonr.string :as rstr]
36
+ [edamame.core :as e]))
34
37
35
38
(defn- throwf [& message]
36
39
(throw (Exception. (apply format message))))
98
101
'? 'try 'break
99
102
'await 'const 'defn 'let 'ns 'def]))
100
103
101
- (def core-vars (set '[map assoc str keyword symbol
102
- dissoc conj vector clj->js js->clj get
103
- hash-map array-map first rest next nth seq]))
104
+ (def core-config (edn/read-string (slurp (io/resource " cherry/cljs.core.edn" ))))
104
105
105
- (def core->js '{clj->js toJs
106
- js->cljs toCljs
107
- hash-map hashMap
108
- array-map arrayMap})
106
+ (def core-vars (:vars core-config))
107
+
108
+ (def core->js (:to-js core-config))
109
+
110
+ (prn core->js)
109
111
110
112
(def prefix-unary-operators (set ['!]))
111
113
437
439
(defn- inner-walk [form]
438
440
(cond
439
441
(unquote? form) (handle-unquote form)
440
- :else (walk inner-walk outer-walk form)))
442
+ :else (walk/walk inner-walk outer-walk form)))
441
443
442
444
(defn- outer-walk [form]
443
445
(cond
446
448
:else form))
447
449
448
450
(defmacro quasiquote [form]
449
- (let [post-form (walk inner-walk outer-walk form)]
451
+ (let [post-form (walk/walk inner-walk outer-walk form)]
450
452
post-form))
451
453
452
454
(defmacro js*
Original file line number Diff line number Diff line change 2
2
'[cherry.transpiler :as cherry]
3
3
)
4
4
5
+ (when-not (System/getProperty " babashka.version" )
6
+ (require '[babashka.process.pprint]))
7
+
5
8
(def in-file (first *command-line-args*))
6
9
(def out-file (:out-file (cherry/transpile-file {:in-file in-file})))
7
10
You can’t perform that action at this time.
0 commit comments