Skip to content

Commit 130e06f

Browse files
committed
Removed ^:exports from datascript.core to enable dead code elimination (reverts #139, closes #191)
1 parent 19bdbd1 commit 130e06f

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Fixed issue when string values were interpreted as lookup refs (#214)
77
- Speed up rschema calculation (#192, thx [Andre R.](https://github.com/rauhs))
88
- Optimize generated JS code by declaring fn arities (#197)
9+
- [ BREAKING ] Removed ^:exports from `datascript.core` to enable dead code elimination (#191). This should only affect you if you were using DataScript from JS and were importing `datascript.core` directly
910

1011
# 0.15.5
1112

src/datascript/core.cljc

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,45 @@
1515
;; SUMMING UP
1616

1717
(defn ^:declared q [q & inputs])
18-
(def ^:export q dq/q)
18+
(def q dq/q)
1919

2020
(defn ^:declared entity [db eid])
21-
(def ^:export entity de/entity)
21+
(def entity de/entity)
2222

23-
(defn ^:export entity-db [^Entity entity]
23+
(defn entity-db [^Entity entity]
2424
{:pre [(de/entity? entity)]}
2525
(.-db entity))
2626

2727
(defn ^:declared datom ([e a v]) ([e a v tx]) ([e a v tx added]))
28-
(def ^:export datom db/datom)
28+
(def datom db/datom)
2929

3030
(defn ^:declared pull [db selector eid])
31-
(def ^:export pull dp/pull)
31+
(def pull dp/pull)
3232

3333
(defn ^:declared pull-many [db selector eids])
34-
(def ^:export pull-many dp/pull-many)
34+
(def pull-many dp/pull-many)
3535

3636
(defn ^:declared touch [e])
37-
(def ^:export touch de/touch)
37+
(def touch de/touch)
3838

3939
(defn ^:declared empty-db ([]) ([schema]))
40-
(def ^:export empty-db db/empty-db)
40+
(def empty-db db/empty-db)
4141

4242
(defn ^:declared init-db ([datoms]) ([datoms schema]))
43-
(def ^:export init-db db/init-db)
43+
(def init-db db/init-db)
4444

4545
(defn ^:declared datom? [x])
46-
(def ^:export datom? db/datom?)
46+
(def datom? db/datom?)
4747

4848
(defn ^:declared db? [x])
49-
(def ^:export db? db/db?)
49+
(def db? db/db?)
5050

51-
(def ^:export ^:const tx0 db/tx0)
51+
(def ^:const tx0 db/tx0)
5252

53-
(defn ^:export is-filtered [x]
53+
(defn is-filtered [x]
5454
(instance? FilteredDB x))
5555

56-
(defn ^:export filter [db pred]
56+
(defn filter [db pred]
5757
{:pre [(db/db? db)]}
5858
(if (is-filtered db)
5959
(let [^FilteredDB fdb db
@@ -62,7 +62,7 @@
6262
(FilteredDB. orig-db #(and (orig-pred %) (pred orig-db %)) (atom 0)))
6363
(FilteredDB. db #(pred db %) (atom 0))))
6464

65-
(defn ^:export with
65+
(defn with
6666
([db tx-data] (with db tx-data nil))
6767
([db tx-data tx-meta]
6868
{:pre [(db/db? db)]}
@@ -75,46 +75,46 @@
7575
:tempids {}
7676
:tx-meta tx-meta}) tx-data))))
7777

78-
(defn ^:export db-with [db tx-data]
78+
(defn db-with [db tx-data]
7979
{:pre [(db/db? db)]}
8080
(:db-after (with db tx-data)))
8181

82-
(defn ^:export datoms
82+
(defn datoms
8383
([db index] {:pre [(db/db? db)]} (db/-datoms db index []))
8484
([db index c1] {:pre [(db/db? db)]} (db/-datoms db index [c1]))
8585
([db index c1 c2] {:pre [(db/db? db)]} (db/-datoms db index [c1 c2]))
8686
([db index c1 c2 c3] {:pre [(db/db? db)]} (db/-datoms db index [c1 c2 c3]))
8787
([db index c1 c2 c3 c4] {:pre [(db/db? db)]} (db/-datoms db index [c1 c2 c3 c4])))
8888

89-
(defn ^:export seek-datoms
89+
(defn seek-datoms
9090
([db index] {:pre [(db/db? db)]} (db/-seek-datoms db index []))
9191
([db index c1] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1]))
9292
([db index c1 c2] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1 c2]))
9393
([db index c1 c2 c3] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1 c2 c3]))
9494
([db index c1 c2 c3 c4] {:pre [(db/db? db)]} (db/-seek-datoms db index [c1 c2 c3 c4])))
9595

96-
(defn ^:export index-range [db attr start end]
96+
(defn index-range [db attr start end]
9797
{:pre [(db/db? db)]}
9898
(db/-index-range db attr start end))
9999

100100
(defn ^:declared entid [db eid])
101-
(def ^:export entid db/entid)
101+
(def entid db/entid)
102102

103103
;; Conn
104104

105-
(defn ^:export conn? [conn]
105+
(defn conn? [conn]
106106
(and #?(:clj (instance? clojure.lang.IDeref conn)
107107
:cljs (satisfies? cljs.core/IDeref conn))
108108
(db/db? @conn)))
109109

110-
(defn ^:export conn-from-db [db]
110+
(defn conn-from-db [db]
111111
(atom db :meta { :listeners (atom {}) }))
112112

113-
(defn ^:export conn-from-datoms
113+
(defn conn-from-datoms
114114
([datoms] (conn-from-db (init-db datoms)))
115115
([datoms schema] (conn-from-db (init-db datoms schema))))
116116

117-
(defn ^:export create-conn
117+
(defn create-conn
118118
([] (conn-from-db (empty-db)))
119119
([schema] (conn-from-db (empty-db schema))))
120120

@@ -127,7 +127,7 @@
127127
(:db-after r))))
128128
@report))
129129

130-
(defn ^:export transact!
130+
(defn transact!
131131
([conn tx-data] (transact! conn tx-data nil))
132132
([conn tx-data tx-meta]
133133
{:pre [(conn? conn)]}
@@ -136,7 +136,7 @@
136136
(callback report))
137137
report)))
138138

139-
(defn ^:export reset-conn!
139+
(defn reset-conn!
140140
([conn db] (reset-conn! conn db nil))
141141
([conn db tx-meta]
142142
(let [report (db/map->TxReport
@@ -151,14 +151,14 @@
151151
(callback report))
152152
db)))
153153

154-
(defn ^:export listen!
154+
(defn listen!
155155
([conn callback] (listen! conn (rand) callback))
156156
([conn key callback]
157157
{:pre [(conn? conn)]}
158158
(swap! (:listeners (meta conn)) assoc key callback)
159159
key))
160160

161-
(defn ^:export unlisten! [conn key]
161+
(defn unlisten! [conn key]
162162
{:pre [(conn? conn)]}
163163
(swap! (:listeners (meta conn)) dissoc key))
164164

@@ -182,7 +182,7 @@
182182

183183
(def ^:private last-tempid (atom -1000000))
184184

185-
(defn ^:export tempid
185+
(defn tempid
186186
([part]
187187
(if (= part :db.part/tx)
188188
:db/current-tx
@@ -192,14 +192,14 @@
192192
:db/current-tx
193193
x)))
194194

195-
(defn ^:export resolve-tempid [_db tempids tempid]
195+
(defn resolve-tempid [_db tempids tempid]
196196
(get tempids tempid))
197197

198-
(defn ^:export db [conn]
198+
(defn db [conn]
199199
{:pre [(conn? conn)]}
200200
@conn)
201201

202-
(defn ^:export transact
202+
(defn transact
203203
([conn tx-data] (transact conn tx-data nil))
204204
([conn tx-data tx-meta]
205205
{:pre [(conn? conn)]}
@@ -235,7 +235,7 @@
235235
IPending
236236
(-realized? [_] @realized)))))
237237

238-
(defn ^:export transact-async
238+
(defn transact-async
239239
([conn tx-data] (transact-async conn tx-data nil))
240240
([conn tx-data tx-meta]
241241
{:pre [(conn? conn)]}
@@ -253,7 +253,7 @@
253253
(< c l) (str (apply str (repeat (- l c) "0")) s)
254254
:else s))))
255255

256-
(defn ^:export squuid
256+
(defn squuid
257257
([]
258258
(squuid #?(:clj (System/currentTimeMillis)
259259
:cljs (.getTime (js/Date.)))))
@@ -278,7 +278,7 @@
278278
(-> (rand-bits 16) (to-hex-string 4))
279279
(-> (rand-bits 16) (to-hex-string 4)))))))
280280

281-
(defn ^:export squuid-time-millis [uuid]
281+
(defn squuid-time-millis [uuid]
282282
#?(:clj (-> (.getMostSignificantBits ^UUID uuid)
283283
(bit-shift-right 32)
284284
(* 1000))

0 commit comments

Comments
 (0)