webpack: Webpack cache not compatible with mini-css-extract-plugin

Bug report

What is the current behavior? module.cache.cacheDirectory is not compatible with mini-css-extract-plugin Receive the following error 2021-01-20-07:34:23 3|admin-webpack | <w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'mini-css-extract-plugin /home/admin/code/experimental/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/home/admin/code/experimental/node_modules/postcss-loader/src/index.js??ruleSet[1].rules[1].use[2]!/home/admin/code/experimental/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!/home/admin/code/experimental/modules/browser/navigation/private/published_doc_interactions.less|0|Compilation/modules|/home/admin/code/experimental/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/home/admin/code/experimental/node_modules/postcss-loader/src/index.js??ruleSet[1].rules[1].use[2]!/home/admin/code/experimental/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!/home/admin/code/experimental/modules/browser/navigation/private/published_doc_interactions.less': No serializer registered for Warning If the current behavior is a bug, please provide the steps to reproduce. Install mini-css-extract-plugin and have webpack config with cache: { type: 'filesystem', cacheDirectory: './cache', },

What is the expected behavior?

Allow plugin to be resolved or to have a way to ignore exclude module plugin. Previously, hard-source-webpack-plugin had a way to exclude module plugins, but since that plugin is no longer needed in due to webpack’s built in cache system it would be nice to either allow it to be resolved with mini-css-extract-plugin or ignore it.

Other relevant information: webpack version: 5.16.0 Node.js version: 14.15.4

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 15
  • Comments: 30 (13 by maintainers)

Most upvoted comments

Go to webpack/lib/ModuleWarning and put console.log(this.name, this.warning, this.details) here https://github.com/webpack/webpack/blob/master/lib/ModuleWarning.js#L40

For anyone else facing the issue. Webpack doesn’t show any warning except the warning about serialization while caching because actual warning happens in child compilers used by mini-css-extract-plugin. And you need to specify { children: true } in webpack config to see the actual message. But it will show a lot of successful message with info about children.

Another option is to set experimentalUseImportModule flag for mini-css-extract-plugin in order to not use child compilers.

@alexander-akait Example in the initial post in this issue: webpack shows this ...<file with warning>... : No serializer registered for Warning with no actual warning text

and after your suggestion to add console.log

Go to webpack/lib/ModuleWarning and put console.log(this.name, this.warning, this.details) here https://github.com/webpack/webpack/blob/master/lib/ModuleWarning.js#L40

The string (45:3) Replace fill-available to stretch, because spec had been changed] will be shown.

stats option is set to minimal in my webpack config

@meskill You have warning in your CSS from autoprefixer, so we can’t cache this module due warning, you need fix warning

I totally understand that, my question was only about webpack output - currently it strips important information which will help to fix warnings

Maybe autoprefixer don’t provide more information, but we can provide this and print file where warning happens. Can you provide small example? Here place to improve https://github.com/webpack-contrib/postcss-loader/blob/master/src/Warning.js

This reply earlier in the thread helped me troubleshoot my silent CSS failure (I had one rule with an empty url that couldn’t resolve): https://github.com/webpack/webpack/issues/12458#issuecomment-763713922

How can we make this a more user-friendly message to explicitly log warnings?

Are these merely getting suppressed by autoprefixer?

It seems like that line of code is our needed serializer right there that should come included

@sokra @alexander-akait Can webpack show more detailed output for warnings like this?

Compare, warning showed by webpack: 2021-01-20-07:34:23 3|admin-webpack | <w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'mini-css-extract-plugin /home/admin/code/experimental/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/home/admin/code/experimental/node_modules/postcss-loader/src/index.js??ruleSet[1].rules[1].use[2]!/home/admin/code/experimental/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!/home/admin/code/experimental/modules/browser/navigation/private/published_doc_interactions.less|0|Compilation/modules|/home/admin/code/experimental/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].use[1]!/home/admin/code/experimental/node_modules/postcss-loader/src/index.js??ruleSet[1].rules[1].use[2]!/home/admin/code/experimental/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[1].use[3]!/home/admin/code/experimental/modules/browser/navigation/private/published_doc_interactions.less': No serializer registered for Warning

And an actual warning from autoprefixer:

2021-01-20-07:48:38 3|admin-webpack   | ModuleWarning [Warning: Warning
2021-01-20-07:48:38 3|admin-webpack   | (45:3) Replace fill-available to stretch, because spec had been changed]

There is no way to figure out why the warning has appeared in the first place without console.log inside webpack/lib