43081j / 43081j/postcss-js-core
Investigate using custom tokenisation for part of the AST
- Lenguaje dominante
- TypeScript
- Estrellas
- 5
- Forks
- 1
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Mira el enfoque existente de extracción de CSS en el codebase y compáralo con el tokenizer de PostCSS. El issue trata los trade-offs entre la tokenización personalizada y la extracción de CSS. Empieza por entender los cálculos actuales de placeholders y el manejo de la sintaxis. Luego, explora si un enfoque híbrido es viable, centrándote en cómo las posiciones de interpolación afectan al parsing.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Área
- compilers, tooling
- Tipo de issue
- Refactorización
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 30/100