43081j / 43081j/postcss-js-core

Investigate using custom tokenisation for part of the AST

Aperta
#7 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
5
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Guarda l’approccio esistente di estrazione CSS nella codebase e confrontalo con il tokenizer di PostCSS. L’issue discute i trade-off tra tokenizzazione custom ed estrazione CSS. Inizia capendo gli attuali calcoli dei placeholder e la gestione della sintassi. Poi, esplora se un approccio ibrido è fattibile, concentrandoti su come le posizioni di interpolazione influenzano il parsing.

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

Valutazione

Ambito
compilers, tooling
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.