csstools / postcss-normalize

Use the parts of normalize.css (or sanitize.css) you need from your browserslist
Creative Commons Zero v1.0 Universal
816 stars 40 forks source link

Question: why is normalize.css bundled #25

Closed jrencz closed 6 years ago

jrencz commented 6 years ago

The fact that this project has some widely known piece of code bundled raises a question in my head. It seems strange to me that content of normalize.css is a part of this repository code, not a dependency. It's not explained in Readme either apart from criptic "uses the non-opinionated version of normalize.css

@jonathantneal have you thought about making normalize.css a peer dependency (yeah, I found https://github.com/jonathantneal/postcss-normalize/issues/3 but it refers to v0.x which was a project of different scope) or at least configurable?

jonathantneal commented 6 years ago

@jrencz, that is a great question.

The shortest answer is that postcss-normalize can’t yet parse the css comments of normalize.css, so an un-opinionated version is used with individual declarations mapped to their corresponding browser targets.

If you would like this project to use normalize.css as a dependency, we would either need someone to write a parser, or we would need to use a version/fork of the project that easily separated the normalizations for us.

Why is this the case? normalize.css uses comments to specify the browsers affected by its normalizations. I did not write a parser to utilize those comments. Those comments also use citation numbers to specify a specific normalization to a specific selector or declaration. Writing a parser to work with those comments might be very difficult.

Instead, I host a copy of normalize.css, and I have manually written a browserslist for each declaration.

I do not currently use that browserslist against a specific version of normalize.css. To do so, I would need write something to throw out the opinionated styles.

Another option that would allow me to use a dependency would be to publish a fork of normalize.css, especially if it already had the normalizations separated for me. I was working on this fork but my regular job had too many commitments, and there wasn’t much interest from my peers to continue the work. That may change given my new job situation, but I don’t yet know.

For the time being, you can see that I still follow the normalize.css issue tracker for changes and comment regularly.

jrencz commented 6 years ago

Great explanation, thank you.

I see that what this project claims to do (i.e. removing parts of normalize.css which are not needed by current list of browsers) is not easy without at least some support on normalize.css side.

I see you're a contributor for normalize.css as well. Was it ever discussed to compile normalize.css from parts digestible by tools like this one instead of having it as one big chunk? If particular rules were split into meaningful chunks it may be easier to maintain a tool like this.

jonathantneal commented 6 years ago

@jrencz, yes, it was discussed, and I might even make a PR for it someday.

See: https://github.com/necolas/normalize.css/issues/222