-
-
Notifications
You must be signed in to change notification settings - Fork 929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SWC as parser #5586
Comments
Very interesting. I'm aware of the buzz around SWC, as it brings a lot to the table. We've touched on the benefits of a more granular parser before in #5061. Especially, parser-level validation of things like mathematical expressions. Am I right in thinking that the parser will already catch We generally bump into issues when working with values or units (e.g. As you said, the benefits to the user are:
There are a number of unknowns, though, especially around languages like SCSS. Right now, we're focused on the 14.0.0 release. Once the dust settles on that, I think we can circle back around to this issue. There's no harm in investigating this further, though. We'll need to weigh up all the pros and cons as things become clearer, but we should be open to the possibility of using the SWC parser. Related: #5499 |
Yes, but due
Yes, we just use
yes, it is just discussion. Anyway, |
Fantastic! The media query parser is a great first candidate as we've some hacky stuff to support range contexts. |
Closing in favour of stylelint/css-parser#2 |
I start work on rust based CSS parser/visitor/codegen - https://github.com/swc-project/swc. I suggest that we should consider to use it as future CSS parser. A lot of great opportunities for us - new rules, better checks, recover mode and more and more. I will not talk about perf and memory usage here.
Notes:
postcss-selector-parser
,postcss-value-parser
,postcss-media-query-parser
packages, they are outdated and doesn't support many CSS features.@media
, selectors, values and etc, most of rules can be rewritten on a much smaller number of lines, which means we need less time for maintenance.isStandard*
utils), but due above point we still havetokens
(on nodes where we can't create AST) so it will be possible still analyze/stringify/reparse them, also we can doswc
parser expandable, this is not difficult, but that would still require someone to implement the parsers. Although to be honest, I'm pretty skeptical about Sass/Less/etc, yes, these are still very popular instruments, but more and more opportunities we can see in CSS, therefore, I think that they are living out their days. Anyway it won't require huge changes fromstylelint-scss
/etc because we still not provide them AST of prelude ofat-rules
(i.e.@media
), values, etc.color: __embeded_value___
, I think we already do it (I have not tested).calc
/min
/max
, AST for an+b syntax and more.Questions/ideas:
swc
topostcss
AST converter for easy migration,postcss
AST is not full, so converter will not be big and not hard to implement.isStandard*
utils, if node hastokens
property (recovery mode), it means no AST present for node and should be ignored.swc
parser too. In roadmap - HTML/XML parser and markdown parser too.Sometimes it's time to look at old things in a new way.
Feel free to questions and feedback, thanks ⭐
The text was updated successfully, but these errors were encountered: