Get rid of externs requirement for pure CLJS builds

Aperta
#498 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
clojure, javascript

Direzione di ricerca

Inizia in datascript.query, in corrispondenza di getter-fn, e ispeziona gli usi di aget alla ricerca di incoerenze nei nomi delle proprietà, quindi esamina il codice relativo alla build JS e le indicazioni in README.md sugli externs. Confronta le build CLJS pure con le build indirizzate a JavaScript; il lavoro è completato quando la build CLJS pura non richiede più externs mentre la build JS esistente continua a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Clojure
Stelle
5.8k
Fork
318
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tonsky/datascript

Tutte le issue di tonsky/datascript

Issue simili

Altre issue su Clojure

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.