Skip to content

Commit 1a23a1d

Browse files
committed
Bring back pnpmfile hack for pnpm/pnpm#3935, which regressed in 9.12.0
1 parent f7c2081 commit 1a23a1d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.pnpmfile.cjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ function afterAllResolved( lockfile ) {
223223
return lockfile;
224224
}
225225

226+
for ( const [ k, v ] of Object.entries( lockfile.packages ) ) {
227+
// Forbid installing webpack without webpack-cli. It results in lots of spurious lockfile changes.
228+
// https://github.com/pnpm/pnpm/issues/3935
229+
if ( k.startsWith( 'webpack@' ) && ! v.optionalDependencies?.[ 'webpack-cli' ] ) {
230+
throw new Error(
231+
"Something you've done is trying to add a dependency on webpack without webpack-cli.\nThis is not allowed, as it tends to result in pnpm lockfile flip-flopping.\nSee https://github.com/pnpm/pnpm/issues/3935 for the upstream bug report.\n"
232+
);
233+
}
234+
}
235+
226236
return lockfile;
227237
}
228238

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)