Description
Bug report
When using css-minimizer-webpack-plugin with npm 7.7.6 and Typescript, the cssnano/node_modules/postcss
is not being installed. As a result, builds fail on this type error.
Actual Behavior
node_modules/css-minimizer-webpack-plugin/types/utils.d.ts:9:30 - error TS2307: Cannot find module 'cssnano/node_modules/postcss' or its corresponding type declarations.
9 export type CssNano = import("cssnano/node_modules/postcss").Plugin<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
Expected Behavior
I know I'm not supposed to say "it should work", but, uh. It looks like you're pulling a type from somewhere that is unreliable. From what I can tell, it's possibly be the result of @types/cssnano
being a direct dependency in your package (and getting it's deps installed), but being a transitive dependency when it's being used. Not sure. What I do know for certain is that in my project that's using css-minimizer-webpack-plugin
, the @types/cssnano
folder looks like this:
When you pull down css-minimizer-webpack-plugin
directly, it looks like this:
How Do We Reproduce?
Using css-minimizer-webpack-plugin
in a Typescript project should trigger this.
Please paste the results of npx webpack-cli info
here, and mention other relevant information
forge [get-css-smaller-nh] $ npx webpack-cli info
System:
OS: macOS 11.6.1
CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
Memory: 1.35 GB / 32.00 GB
Binaries:
Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.7.6 - ~/.nvm/versions/node/v15.14.0/bin/npm
Browsers:
Chrome: 96.0.4664.110
Firefox: 91.4.0
Safari: 15.2
Packages:
css-loader: ^6.2.0 => 6.5.1
css-minimizer-webpack-plugin: ^3.1.4 => 3.3.0
csv-loader: ^3.0.3 => 3.0.3
filemanager-webpack-plugin: ^6.1.4 => 6.1.7
html-webpack-plugin: ^5.3.2 => 5.5.0
style-loader: ^3.2.1 => 3.3.1
ts-loader: ^9.2.3 => 9.2.6
webpack: ^5.45.1 => 5.65.0
webpack-bundle-analyzer: ^4.5.0 => 4.5.0
webpack-cli: ^4.7.2 => 4.9.1
webpack-dev-server: ^3.11.2 => 3.11.3
xml-loader: ^1.2.1 => 1.2.1
I suspect that if you change the type to point at postcss
instead of cssnano/node_modules/postcss
that this error will go away, but you may need to add @types/postcss
to your dependencies.