-
-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with datalog under advanced compilation #30
Comments
@robert-stuttaford , sorry, I was really busy and haven’t looked at your issue. First, make sure your project.clj looks like this:
Second, what exact version of DS you use? Third, if that’s possible, maybe you can give me access to source code so I can take a look at it? Maybe partially (I’m interested most about parts where you create data, where you select it and where you display it, and project.clj of course). prokopov@gmail.com |
Thanks @tonsky! I'm using version All the source code is here: https://github.com/robert-stuttaford/stuttaford.me/blob/master/src/stuttaford/radiant.cljs The datalog stuff is here: https://github.com/robert-stuttaford/stuttaford.me/blob/master/src/stuttaford/radiant/datalog.cljs And the database is created here: The source data is in the source of the page at: http://www.stuttaford.me/radiant-advanced/ It's the really big EDN blob. Thanks for taking the time to look into it! |
Oh, missed that when looked at your github. Actually I have a hypothesis, try |
Anticipating that, I had already printed the output of several things directly on the page at: http://www.stuttaford.me/radiant-advanced/ In order, it's the query as successfully parsed by Datascript, the entire database, and finally the result of that query on that database. Here's the source: You can see that the symbols are identical; for example, here's the parsed query: {:find [?e ?a ?v], :in [$], :where [[?e ?a ?v]]} |
You have pretty complex build schema out there :) So this is what I believe is going on: you build core modules and radiant modules separately and then include them both on a single page. Advanced compilation doesn’t work like that. If you compile something separately you’ll probably get same symbols assigned in first and in a second case to very different things. Google Closure compile does aggressive renaming in order to minimize code size, so it renames everything to names like Also you put Google Analytics to the page. It binds to |
I'm using shadow (https://github.com/thheller/shadow-build) instead of cljsbuild which supports the underlying Google Closure module capability - that is, multiple interoperating js files. If this were not so, a lot more than just the Datalog query would be broken, as all the 3rd-party libraries are in Even so, I'll build it as a single JS and see if that helps. Thanks for the tip about Google Analytics, I'll include externs for that as well. |
@robert-stuttaford Can you keep me in the loop if you can make it work with cljs-compile? Maybe there’s some incompatibility between DS and shadow-build, if that’s the case, I would look into that deeper |
Here’s what I found: If you put externs file to src/ folder of your project (I used Probably related comment here https://github.com/thheller/shadow-build/blob/master/src/clj/shadow/cljs/build.clj#L910 I’ll close the issue for now as problem seems to be not in DataScript |
I managed to get it work: diff --git a/project.clj b/project.clj
index e9a55bf..fdb6418 100644
--- a/project.clj
+++ b/project.clj
@@ -25,13 +25,13 @@
:profiles {:dev {:source-paths ["dev"]
:dependencies
[[org.clojure/tools.namespace "0.2.7"]
- [thheller/shadow-build "0.9.3" :exclusions [org.clojure/clojurescript]]
- [org.clojure/clojurescript "0.0-2342"]
+ [thheller/shadow-build "0.9.5" :exclusions [org.clojure/clojurescript]]
+ [org.clojure/clojurescript "0.0-2371"]
[om "0.7.3"]
[prismatic/om-tools "0.3.3" :exclusions [org.clojure/clojure]]
[racehub/om-bootstrap "0.2.9" :exclusions [org.clojure/clojure]]
[sablono "0.2.22" :exclusions [com.facebook/react]]
- [datascript "0.4.0"]
+ [datascript "0.5.1" :exclusions [org.clojure/clojurescript]]
[com.cemerick/url "0.1.1"]
[cljs-http "0.1.16"]
[secretary "1.2.1"]]
@@ -49,6 +49,5 @@
sablono.core
secretary.core
datascript]
- :externs ["datascript/externs.js"]
:modules [{:id :codex :main stuttaford.codex}
{:id :radiant :main stuttaford.radiant}]})
diff --git a/dev/shadow.clj b/dev/shadow.clj
index 313a812..7938c9e 100644
--- a/dev/shadow.clj
+++ b/dev/shadow.clj
@@ -46,7 +46,8 @@
:pretty-print true}
:production {:optimizations :advanced
:pretty-print false
- :externs (compose-externs externs)}))))
+ :externs (compose-externs externs)
+ :ups-externs ["datascript/externs.js"]}))))
(defn configure-source-paths [state source-paths]
(reduce (fn [state source-path] Still puzzled though what’s the difference between Here’s part I looked at: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/closure.clj#L188 |
Hey, never heard of Seems like a 3rd party library is supposed to ship a |
It seems like a useful option to have though. Otherwise everyone that uses a library like datascript must remember to also provide the "datascript/externs.js" in the build. Maybe it would be prudent to discuss this issue in the CLJS Jira or Google Group, seems like a quality of life change that should have a default solution not one that every build tool/library handles differently. |
@thheller totally agree! thanks for bringing up that issue. Posted on google group: https://groups.google.com/d/topic/clojurescript/LtFMDxc5D00/discussion |
I built Radiant, a Datascript sandbox, recently. In it, I have found an issue with Datalog under advanced compilation.
This page hosts the
:optimizations :none
version of Radiant:http://www.stuttaford.me/radiant/
As you can see, the datalog query runs and produces a result table.
This page hosts the
:optimizations :advanced
version of Radiant:http://www.stuttaford.me/radiant-advanced/
You can see that I have printed out the parsed query, the full database, and the raw result from the datalog query above the result table.
The results do not match that of the first link. Looking at the results, for some reason, all the
e
andv
values are missing.You can visit the "Datoms" section to see that the
datoms
function is working as expected.How do I go about debugging this?
I have already ruled out the possibility of externs not being used. They are.
Thank you for your time :-)
The text was updated successfully, but these errors were encountered: