You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#527 introduced functionality to check for the presence of PostCSS in a project's package.json in order to log a warning if the version didn't match. The functionality is implemented by parsing package.json and checking pkg.dependencies.postcss and pkg.devDependencies.postcss.
However, neither dependencies nor devDependencies is a required field of package.json. If either of these fields are missing in package.json, a TypeError: Cannot read property 'postcss' of undefined will be raised.
// valid package.json that will cause a TypeError{"name": "my-project-without-dependencies","version": "0.0.0","devDependencies": {// ...}}// workaround - add an empty dependencies object{"name": "my-project-without-dependencies","version": "0.0.0","dependencies": {},"devDependencies": {// ...}}
Actual Behavior
See above
Expected Behavior
A project need not define dependencies nor devDependencies for this loader to work. In my specific use case, the project in question is part of a monorepo, where all dev dependencies are hoisted to the workplace package.json and the project's package.json has no dev dependencies. I'm not sure if having postcss declared in a monorepo root package.json but not a sub-project package.json would cause further issues.
As an aside (and after reading through the initial issue thread at #507), I understand why this functionality was implemented, but in my personal opinion, "checking that peer dependencies are properly installed" should be outside the scope of any functionality in this module besides declaring the peer dep in package.json.
How Do We Reproduce?
Initialize a project with postcss-loader and webpack
Delete dependencies in package.json
Run webpack
Observe TypeError raise
Please paste the results of npx webpack info here, and mention other relevant information
npm v7 automatically install peer deps, yarn throws an errors (for me it is right behavior, but this question about another problem), npm v6 output warnings, developer should read output from package manager, and packages should not check dependencies except optionalDependencies (try/catch)
Bug report
#527 introduced functionality to check for the presence of PostCSS in a project's
package.json
in order to log a warning if the version didn't match. The functionality is implemented by parsingpackage.json
and checkingpkg.dependencies.postcss
andpkg.devDependencies.postcss
.However, neither
dependencies
nordevDependencies
is a required field ofpackage.json
. If either of these fields are missing inpackage.json
, aTypeError: Cannot read property 'postcss' of undefined
will be raised.Actual Behavior
See above
Expected Behavior
A project need not define
dependencies
nordevDependencies
for this loader to work. In my specific use case, the project in question is part of a monorepo, where all dev dependencies are hoisted to the workplacepackage.json
and the project's package.json has no dev dependencies. I'm not sure if havingpostcss
declared in a monorepo root package.json but not a sub-project package.json would cause further issues.As an aside (and after reading through the initial issue thread at #507), I understand why this functionality was implemented, but in my personal opinion, "checking that peer dependencies are properly installed" should be outside the scope of any functionality in this module besides declaring the peer dep in
package.json
.How Do We Reproduce?
dependencies
in package.jsonwebpack
Please paste the results of
npx webpack info
here, and mention other relevant informationThe text was updated successfully, but these errors were encountered: