postcss / postcss-calc

PostCSS plugin to reduce calc()
MIT License
212 stars 34 forks source link

update: use PostCSS 8 API. #125

Closed ludofischer closed 3 years ago

ludofischer commented 3 years ago

I've noticed https://github.com/cssnano/cssnano/pull/954 assumes there's a version of this with the PostCSS 8 API, but I could not find it either a release, pull request or branch, so here it it.

I've used the visitor API thinking it should be safe from infinite loops, as once the calc() declarations are gone, the transform() function will exit immediately.

Semigradsky commented 3 years ago

.travis.yml should be updated.

ludofischer commented 3 years ago

I would like to add an integration test with other plugins on realistic CSS, to check that processing terminates without errors. But I am unsure what plugins and sample CSS to pick. Maybe autoprefixer?

ludofischer commented 3 years ago

I think this pull request should not be merged in this state, there's a chance of infinite loops apprearing. I've added a test that produces an infinite loop: adding a plugin that changes whitespace inside the calc() property. I guess the 'right' solution would be to skip writing the value if we detect the parsed value AST are equivalent? Or just use Once() :-)?

alexander-akait commented 3 years ago

@ludofischer Let's use Once

alexander-akait commented 3 years ago

@Semigradsky Can you help and do major release due https://github.com/cssnano/cssnano/pull/975#issuecomment-752523677?

Semigradsky commented 3 years ago

Done https://github.com/postcss/postcss-calc/releases/tag/v8.0.0