Skip to content

Commit ef3305b

Browse files
authored
Remove most pnpm hoisting, fix phantom deps (#24096)
We've long had pnpm's public hoisting disabled, but it also privately hoists everything into `node_modules/.pnpm/node_modules/` for compatibility with packages that have undeclared dependencies. Let's disable most of that private hoisting and see what turns up. Changes of note: * We still hoist a bunch of eslint plugins (and one prettier plugin) as untangling that mess seems like enough work to put off for later. * Only a few upstream packages have bugs that need working around: * `@mdx-js/loader`: mdx-js/mdx#2019 * `@automattic/components`: Missing dep on `@wordpress/base-styles`. And the next version will probably be unusable for us due to added `i18n-calypso`. * `@automattic/popup-monitor`: Missing dep on `events`. * markdown-it`: Missing dep on `punycode`. markdown-it/markdown-it#230 * `@samverschueren/stream-to-observable`: Outdated dep on `any-observable`. SamVerschueren/stream-to-observable#9 Hacking around that should also fix p1649254510834369-slack-CBG1CP4EN. * `git-node-fs`: Missing peer dep on `js-git`. creationix/git-node-fs#8 * `fetch-mock`'s peer dep on `node-fetch` is optional, but only because they also allow running in-browser. It's required for node. * Added `webpack-cli` alongside `webpack` everywhere to make sure p1650571211251179-slack-CBG1CP4EN is fixed. Dropped Webpack entirely from Boost instead though, they don't use it. * Had our webpack-config package point to its own copy of `@babel/runtime` instead of making that a peer dep. * Jetpack's extensions tests use a ton of `@wordpress/` packages that weren't being directly depended on.
1 parent 850be64 commit ef3305b

File tree

41 files changed

+542
-1477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+542
-1477
lines changed

.npmrc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,21 @@ strict-peer-dependencies = true
44
# Force node version
55
engine-strict = true
66

7-
# Default, minus eslint.
8-
public-hoist-pattern=['*types*', '@prettier/plugin-*', '*prettier-plugin-*']
7+
# No hoisting by default.
8+
hoist-pattern=[]
9+
public-hoist-pattern=[]
10+
11+
# Hoist eslint crap. Too many problems there to figure out right now.
12+
# Probably we need to move more of the different eslint configs into tools/js-tools/eslintrc/.
13+
hoist-pattern[]='@babel/eslint-parser'
14+
hoist-pattern[]='@typescript-eslint/parser'
15+
hoist-pattern[]='@typescript-eslint/eslint-plugin'
16+
hoist-pattern[]='@wordpress/eslint-plugin'
17+
hoist-pattern[]='eslint-config-prettier'
18+
hoist-pattern[]='eslint-import-resolver-node'
19+
hoist-pattern[]='eslint-plugin-es5'
20+
hoist-pattern[]='eslint-plugin-playwright'
21+
hoist-pattern[]='eslint-plugin-react'
22+
23+
# Hoist prettier crap too.
24+
hoist-pattern[]='prettier-plugin-svelte'

.pnpmfile.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ function fixDeps( pkg ) {
2020
pkg.dependencies[ '@wordpress/components' ] = '^19.2.0';
2121
}
2222
}
23+
if ( pkg.name === '@automattic/components' ) {
24+
// 1.0.0-alpha.3 published 2020-11-11. Not that we want alpha.4, they added an i18n-calypso dep (ugh).
25+
if ( ! pkg.dependencies[ '@wordpress/base-styles' ] ) {
26+
// Depends on this but doesn't specify it.
27+
pkg.dependencies[ '@wordpress/base-styles' ] = '^4.0.4';
28+
}
29+
}
30+
31+
// Depends on events but doesn't declare it.
32+
if ( pkg.name === '@automattic/popup-monitor' && ! pkg.dependencies.events ) {
33+
pkg.dependencies.events = '^3.3.0';
34+
}
35+
36+
// Depends on punycode but doesn't declare it.
37+
// https://github.com/markdown-it/markdown-it/issues/230
38+
if ( pkg.name === 'markdown-it' && ! pkg.dependencies.punycode ) {
39+
pkg.dependencies.punycode = '^2.1.1';
40+
}
2341

2442
// Even though Storybook works with webpack 5, they still have a bunch of deps on webpack4.
2543
if ( pkg.name.startsWith( '@storybook/' ) ) {
@@ -37,6 +55,15 @@ function fixDeps( pkg ) {
3755
}
3856
}
3957

58+
// Outdated dep.
59+
// https://github.com/SamVerschueren/stream-to-observable/pull/9
60+
if (
61+
pkg.name === '@samverschueren/stream-to-observable' &&
62+
pkg.dependencies[ 'any-observable' ] === '^0.3.0'
63+
) {
64+
pkg.dependencies[ 'any-observable' ] = '^0.5.1';
65+
}
66+
4067
// Project is supposedly not dead, but still isn't being updated.
4168
// For our purposes at least it seems to work fine with jest-environment-jsdom 27.
4269
// https://github.com/enzymejs/enzyme-matchers/issues/353
@@ -95,6 +122,12 @@ function fixPeerDeps( pkg ) {
95122
delete pkg.peerDependencies?.[ 'eslint-plugin-node' ];
96123
}
97124

125+
// Peer-depends on js-git but doesn't declare it.
126+
// https://github.com/creationix/git-node-fs/pull/8
127+
if ( pkg.name === 'git-node-fs' && ! pkg.peerDependencies?.[ 'js-git' ] ) {
128+
pkg.peerDependencies[ 'js-git' ] = '*';
129+
}
130+
98131
// Outdated. Looks like they're going to drop the eslint-config-wpcalypso package entirely with
99132
// eslint-plugin-wpcalypso 5.1.0, but they haven't released that yet.
100133
if ( pkg.name === 'eslint-config-wpcalypso' ) {

0 commit comments

Comments
 (0)