csstools / postcss-nesting

Nest style rules inside each other

Home Page:https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: throw error if used by unsupported PostCSS version

OliverJAsh opened this issue · comments

Hi there! Thanks for the fantastic library.

I recently ran into an issue whereby my nesting output was very messed up:

I believe the culprit ended up being the fact I was using postcss-nesting 2.3.0 within postcss 6, and postcss-nesting 2.3.0 does not have support for postcss 6. I fixed the issue by upgrading to postcss-nesting 3.0.0, which is the first version that does have support for postcss 6.

I wanted to suggest that we make postcss-nesting throw an error early if it is used by a version of postcss that it does not officially support, instead of the current behaviour which is to fail silently.

This took me awhile to debug and I'm keen to improve the experience for the next user who hits a similar problem.

What do you think? :-)

Cheers,
Oliver

PostCSS Nesting 3x was released over a year ago. The issue/request you are making was addressed in PostCSS 6, which was also released in May of 2017. I’m curious how you ended up on an older version for so long, relative to many npm packages.

I’m not sure how I can help you other than to request you use PostCSS 6 moving forward.

If in the future the current version of postcss-nesting was used by the next version of postcss, would postcss-nesting error loudly or silently?

I suspect it would fail silently, like the case I ran into? Unless error handling has been improved since then?

I just want to avoid this pain for future users when they are upgrading libraries. There is no warning/error whatsoever about the wrong versions being used. This is a bug?

PostCSS v6 should have warned you about using a plugin depending on PostCSS v5.

PostCSS doesn't do that. It only warnings about the plugin version if the plugin throws an error. See postcss/postcss#163.

I posted the suggestion with PostCSS: postcss/postcss#1165