Skip to content

add known_pseudo_classes to the codebase to prevent unnecessary invalidations on :global and :local#1231

Open
calebdwilliams wants to merge 1 commit into
parcel-bundler:masterfrom
calebdwilliams:add-known_pseudo_classes
Open

add known_pseudo_classes to the codebase to prevent unnecessary invalidations on :global and :local#1231
calebdwilliams wants to merge 1 commit into
parcel-bundler:masterfrom
calebdwilliams:add-known_pseudo_classes

Conversation

@calebdwilliams

Copy link
Copy Markdown

Why?

At Slack we use lightningcss for our CSS minification, but not for CSS modules. We have noticed lightningcss will wrap unknown pseudos with an :is() selector which causes unnecessary invalidations in our app because CSS module processing comes later in our toolchain.

What?

This pull request adds optional support for unknown pseudos to bypass lightningcss' modifications of selectors like :global and :local so that we can avoid the unnecessary CSS invalidation those additions cause.

Notes

This is my first time contributing to this project and one of my first times working with Rust. I'm happy to field any suggestions or feedback you might have.

@calebdwilliams

Copy link
Copy Markdown
Author

This should resolve #1079

@calebdwilliams

Copy link
Copy Markdown
Author

@devongovett sorry for the bump here, this is just high on my priority list at the moment so I needed to follow up. If this isn't something you're interested in, let me know. I do have a custom visitor written that does this same thing more or less, but would greatly prefer to be able to use an actual API from lightningcss.

@zalishchuk

Copy link
Copy Markdown

@calebdwilliams I wouldn't expect a quick response here.

Personally, I decided to move away from Lightning CSS for now and use other tools until things improve. Although we experienced a slight dip in build performance, I found it difficult to accept some of the less obvious "optimizations" and "transformations" just like shown in this pull request, which cannot be disabled. The minification optimizations are more aggressive, but alternative tools label them as "unsafe" and exclude them from default presets.

I also noticed :is() selector usage when I updated my browserslist, and that played a part in my decision to stop using LightningCSS.

LightningCSS is a fantastic and blazing-fast tool, but sometimes stability and predictability take priority over pure performance.

@devongovett

Copy link
Copy Markdown
Member

As the original bug said, this seems to have more to do with there being a visitor than the :global pseudo alone. Example (turn off the visitor and it seems right). Seems like we should debug that.

@calebdwilliams

Copy link
Copy Markdown
Author

This still happens in a fresh instance of lightningcss as well. I would create a reproduction but I have limited connectivity for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants