csstools / postcss-preset-env

Convert modern CSS into something browsers understand
https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env
Creative Commons Zero v1.0 Universal
2.22k stars 90 forks source link

ParserError on particular syntax #184

Closed allenrabinovich closed 2 years ago

allenrabinovich commented 4 years ago

I am getting a postcss-preset-env ParserError that comes up on what appears to be valid CSS. I isolated it to this statement:

:root { --foo:calc(var(--bazz)*-1); }

The error disappears when a space is added after the *:

:root { --foo:calc(var(--bazz)* -1); }

The error is:

ERROR in ./styles/views/home.scss (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src!./node_modules/sass-loader/dist/cjs.js??ref--6-3!./styles/views/home.scss) Module build failed (from ./node_modules/postcss-loader/src/index.js): ParserError: Syntax Error at line: 1, column 18 at Parser.error (app_folder/src/node_modules/postcss-values-parser/lib/parser.js:127:11) at Parser.operator (app_folder/src/node_modules/postcss-values-parser/lib/parser.js:162:20) at Parser.parseTokens (app_folder/src/node_modules/postcss-values-parser/lib/parser.js:245:14) at Parser.loop (app_folder/src/node_modules/postcss-values-parser/lib/parser.js:132:12) at Parser.parse (app_folder/src/node_modules/postcss-values-parser/lib/parser.js:51:17) at parse (app_folder/src/node_modules/postcss-custom-properties/index.cjs.js:47:30) at rule.nodes.slice.forEach.decl (app_folder/src/node_modules/postcss-custom-properties/index.cjs.js:73:42) at Array.forEach (<anonymous>) at root.nodes.slice.forEach.rule (app_folder/src/node_modules/postcss-custom-properties/index.cjs.js:69:26) at Array.forEach (<anonymous>) at getCustomPropertiesFromRoot (app_folder/src/node_modules/postcss-custom-properties/index.cjs.js:65:22) at Object.syncTransform [as plugin] (app_folder/src/node_modules/postcss-custom-properties/index.cjs.js:519:30) at promise.then (app_folder/src/node_modules/postcss-preset-env/index.js:443:97)

arshaw commented 4 years ago

Hey @allenrabinovich , I found that https://github.com/csstools/postcss-preset-env/issues/163 is nearly the same bug. I posted a repro there. Could you thumbs-up that issue? Hopefully we can use that ticket to express the general-case.

romainmenke commented 2 years ago

Hi @allenrabinovich all plugins have been migrated to postcss-value-parser which resolves this issue.

If the bug persists with the latest versions you can open a new issue here : https://github.com/csstools/postcss-plugins

The plugin has been moved there and this repo will be archived, preventing further discussion here.