webpack-contrib / postcss-loader

PostCSS loader for webpack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exceptions in postcssFactory are swallowed

dko-slapdash opened this issue · comments

Hi.

postcss-loader/src/index.js

Lines 114 to 121 in a0c6e3f

try {
processor = postcssFactory(plugins);
result = await processor.process(root || content, processOptions);
} catch (error) {
// Check postcss versions to avoid using PostCSS 7.
// For caching reasons, we use the readFileSync and existsSync functions from the context,
// not the functions from the `fs` module.
if (!hasExplicitDependencyOnPostCSS && processor.version.startsWith("7.")) {

There is a bug on L121: in case the exception is thrown before processor is initialized (in my case, it was "true is not a PostCSS plugin"), then that exception is swallowed, and the code fails in processor.version.startsWith check instead.

The fix would be to add && processor condition to this "if".

Please always use the issue template