datascript

Peter Sagerson 2021-11-19T16:26:22.021600Z

Playing with DataScript in the browser, I started having trouble as soon as I tried a build with optimizations. This trivial case reproduces it (node and browser behave the same):

(defn main
  []
  (let [conn (ds/create-conn)]
    (ds/transact! conn [[:db/add 1 :person/name "Alice"]])
    (prn (ds/q '[:find [?e ?v]
                 :where [?e :person/name ?v]]
               @conn))))
> bin/shadow-cljs compile node
[:node] Compiling ...
[:node] Build completed. (65 files, 64 compiled, 0 warnings, 9.90s)
> node build/app.js
[1 "Alice"]

> bin/shadow-cljs release node
[:node] Compiling ...
[:node] Build completed. (65 files, 26 compiled, 0 warnings, 19.27s)
> node build/app.js
[1 #object[Function]]

> bin/shadow-cljs --debug release node
[:node] Compiling ...
[:node] Build completed. (65 files, 26 compiled, 0 warnings, 21.83s)
> node build/app.js
[1 nil]
Am I missing something? (Full source at https://github.com/psagers/datascript-shadow).

dmegas 2021-11-19T18:50:20.021900Z

I’d be interested to know if you find anything out. I’m facing a similar issue but thought that it was because I was storing a File object; it is working with :simple optimisations but not with :advanced.

dmegas 2021-11-19T18:52:00.022100Z

Maybe https://github.com/tonsky/datascript/issues/298 and the related https://github.com/tonsky/datascript/pull/216 could help

Peter Sagerson 2021-11-19T19:01:41.022400Z

That seems to have done it, thanks! ClojureScript/Shadow CLJS have gotten so good at extern inference for interop, it's been a while since I've had to deal with them explicitly.

dmegas 2021-11-19T19:05:55.022600Z

yes! it worked for me, too 😄

Jack Park 2021-11-29T20:04:20.023500Z

Strange: the URL to datascript-shadow seems broken - no such codebase at that repo

Peter Sagerson 2021-11-29T20:07:44.024400Z

I took it down since the problem was solved. There was nothing unique or interesting in it. https://github.com/tonsky/datascript/wiki/Tips-&-tricks#externs-and-shadow-cljs