43081j / 43081j/postcss-js-core

Investigate using custom tokenisation for part of the AST

オープン
#7 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
5
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

codebase 内の既存の CSS 抽出アプローチを確認し、PostCSS の tokenizer と比較してください。この issue では、カスタム tokenization と CSS 抽出の間の trade-off について議論しています。まず、現在の placeholder 計算と構文処理を理解するところから始めてください。その後、補間位置が parsing にどう影響するかに焦点を当てて、ハイブリッドアプローチが実現可能かを調査してください。

索引モデルが issue の本文から書いたものです。

評価

領域
compilers, tooling
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。