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)
Go to
webpack/lib/ModuleWarning
and putconsole.log(this.name, this.warning, this.details)
here https://github.com/webpack/webpack/blob/master/lib/ModuleWarning.js#L40For 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 textand after your suggestion to add console.log
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 configI 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.jsThis 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:
There is no way to figure out why the warning has appeared in the first place without console.log inside webpack/lib