43081j / 43081j/postcss-js-core

Investigate using custom tokenisation for part of the AST

Đang mở
#7 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
5
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Hãy xem cách tiếp cận trích xuất CSS hiện có trong codebase và so sánh nó với tokenizer của PostCSS. Issue thảo luận các trade-off giữa tokenization tùy chỉnh và trích xuất CSS. Bắt đầu bằng cách hiểu các tính toán placeholder hiện tại và cách xử lý cú pháp. Sau đó, tìm hiểu liệu một cách tiếp cận hybrid có khả thi không, tập trung vào cách các vị trí interpolation ảnh hưởng đến parsing.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Lĩnh vực
compilers, tooling
Loại issue
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.