43081j / 43081j/postcss-js-core

Investigate using custom tokenisation for part of the AST

Offen
#7 9 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
5
Forks
1
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

As seen in the original iteration of this core, it is possible to achieve most of what we have here through using a custom tokeniser.

Initially, we didn't do this since we wanted to avoid duplication of code (postcss tokeniser, parser). However, if the complexity of our placeholder calculations and what not exceeds that of a tokeniser, it may be a viable solution again.

For terminology ill call the two approaches as follows:

* Custom tokenisation
* CSS extraction

## CSS extraction

Pros:
* Reuse the postcss parser/tokeniser, no code duplication needed
* Customisable for different syntaxes (we got lucky so far that the ones we have are all similar, that won't be the case in future)

Cons:
* Certain interpolation positions can cause syntax problems, though are rare
* AST doesn't actually contain nodes representing the JS part of the syntax
* Some stylelint rules could fire for placeholder syntax unintentionally

## Custom tokenisation

Pros:
* AST contains the entire source, JS and CSS
* Interpolation can happen anywhere

Cons:
* Duplication of the postcss parser and tokeniser increases maintenance burden/bug risk
* AST will be more complex
* Nested stylesheets could be difficult
* Less customisable across syntaxes

---

a middle ground could actually be ideal, if any of us figure out what exactly that is.

@hudochenkov it would be super nice to get your views on this stuff even if you choose not to contribute the solution

if you don't have a stab at the custom tokenisation in here, i will, for sake of comparison. then we can see where to go from there.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Sehen Sie sich den bestehenden Ansatz zur CSS-Extraktion in der Codebase an und vergleichen Sie ihn mit dem Tokenizer von PostCSS. Das Issue diskutiert Trade-offs zwischen eigener Tokenisierung und CSS-Extraktion. Beginnen Sie damit, die aktuellen Platzhalterberechnungen und die Syntaxbehandlung zu verstehen. Untersuchen Sie dann, ob ein hybrider Ansatz machbar ist, mit Fokus darauf, wie Interpolationspositionen das Parsing beeinflussen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Bereich
compilers, tooling
Issue-Typ
Refactoring
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.