43081j / 43081j/postcss-js-core

Investigate using custom tokenisation for part of the AST

Ouverte
#7 9 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
TypeScript
Étoiles
5
Forks
1
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Examinez l’approche existante d’extraction CSS dans la codebase et comparez-la avec le tokenizer de PostCSS. L’issue discute des trade-offs entre la tokenisation personnalisée et l’extraction CSS. Commencez par comprendre les calculs actuels de placeholders et la gestion de la syntaxe. Ensuite, explorez si une approche hybride est faisable, en vous concentrant sur la façon dont les positions d’interpolation affectent le parsing.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Domaine
compilers, tooling
Type d'issue
Refactorisation
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.