Get rid of externs requirement for pure CLJS builds
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- clojure, javascript
- Domain
- build-system, database
Research direction
Start in datascript.query at the getter-fn and inspect the aget uses for property-name inconsistencies, then review the JS build-related code and README.md guidance about externs. Compare pure CLJS and JavaScript-targeted builds; done means the pure CLJS build no longer requires externs while the existing JS build continues functioning.
Written by the indexing model from the issue text.
Description
There is a very long open issue that datascript requires externs even for pure CLJS compilation. This should never be neccessary for builds where all code is part of the build. Given that shadow-cljs doesn't add externs by default this creates problems. It even has become part of the entry README.md since I assume this is a common issue.
I had a suspicion what the problem is and used AI to confirm. It did, but I do not know enough about this codebase to know if its suggested fixes would actually work. So, here goes the problem.
The code is running into the Inconsistent Property Names problem. Meaning that some places use foo.e and other use foo["e"]. Or more likely the CLJS variants of (.-e foo) and (aget e "foo") (or unchecked-get or any other string based property access). I can see several uses of aget in the codebase, most notably the getter-fn in datascript.query. Given that the set of property names is known it can just use direct getters and not mix in string lookups.
There is also another situation where code contains forced goog/exportSymbol code that is also never necessary for pure CLJS builds and should only be present for the JS targetted builds, not part of the raw sources the CLJS builds will use. But that is a different unrelated issue. Just leads to a lingering datascript global that is also causing problems in ESM builds.
I'd advise moving all the JS build related bits into their own files and doing that build with externs. That would leave the JS build functioning as is, while likely fixing all the CLJS related build issues.
I have no interest in pursuing this myself any further, but given that AI can most definitely fix this, I thought I would bring it up just in case there is any interest in "fixing" the current situation.
- Dominant language
- Clojure
- Stars
- 5.8k
- Forks
- 318
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tonsky/datascript
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
tonsky/datascript#489 ·
-
Stack overflow when transacting :db.type/tupleAttrs with a :db.type/ref attr through :db.fn/call Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tonsky/datascript#483 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tonsky/datascript#470 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tonsky/datascript#441 · 1 comment · 3 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
tonsky/datascript#434 · 2 comments ·
All issues in tonsky/datascript
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
.Team/Metabot Priority:P3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
needs triage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
scalar-labs/scalar-jepsen#222 · 1 comment ·