Skip to content

Commit 06b4e58

Browse files
committed
refactor: migrate patch-package to native pnpm patch
patch-package and pnpm don't play well together. patch-package writes to the top-level node_modules/<pkg>/ path; under pnpm's strict layout that location is a symlink into the .pnpm/<pkg>@<ver>/node_modules/<pkg>/ store directory, but patch-package doesn't follow the symlink to patch the canonical file. The patch silently fails to apply, and the postinstall step reports success regardless. Concrete impact on this branch (before this commit): the lone patch in patches/ — typescript-react-function-component-props-handler+1.1.1 — never took effect under pnpm. That patch adds an Array.isArray guard before reading .params.length inside react-docgen's prop-extraction pipeline; without it, `pnpm generate-readmes` throws `TypeError: Cannot read properties of undefined (reading 'length')` on certain components. Native pnpm patch writes the patched file directly into the .pnpm store via `pnpm.patchedDependencies` in root package.json. The patch is now correctly applied at install time. Mechanics: - `pnpm patch typescript-react-function-component-props-handler@1.1.1` → applied the same Array.isArray fix - `pnpm patch-commit` wrote patches/typescript-react-function-component-props-handler@1.1.1.patch (note `@` separator vs patch-package's `+`) and the patchedDependencies entry in root package.json - Deleted patches/typescript-react-function-component-props-handler+1.1.1.patch - Removed `patch-package` from devDependencies - Removed `pnpm patch-package` invocation from scripts/postinstall.sh - Reinstalled to regenerate pnpm-lock.yaml (patch-package + transitive deps removed, patch hash recorded against the patched package) Verification: `pnpm generate-readmes` now runs to completion. Stale README content in 10 packages exists as a separate concern — fixed in the generator/tooling here; regenerating the actual README outputs is a separate maintenance task. Resolves FEC-924 follow-up: "patch-package → native pnpm patch". Side-effect: also resolves "broken pnpm generate-readmes" since the generator's underlying bug is what the patch was written to fix.
1 parent a7d16a3 commit 06b4e58

5 files changed

Lines changed: 25 additions & 122 deletions

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
"tar-fs@^2.0.0": "^2.1.4",
119119
"tar-fs@^3.0.6": "^3.1.1",
120120
"trim@0.0.1": "^0.0.3"
121+
},
122+
"patchedDependencies": {
123+
"typescript-react-function-component-props-handler@1.1.1": "patches/typescript-react-function-component-props-handler@1.1.1.patch"
121124
}
122125
},
123126
"engines": {
@@ -190,7 +193,6 @@
190193
"moment": "2.30.1",
191194
"moment-timezone": "0.6.0",
192195
"omit-empty-es": "1.2.0",
193-
"patch-package": "^8.0.1",
194196
"postcss": "8.5.6",
195197
"postcss-styled-syntax": "^0.7.0",
196198
"postcss-syntax": "^0.36.2",

patches/typescript-react-function-component-props-handler+1.1.1.patch

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/index.js b/index.js
2+
index 5c636b98ce6714daed7281e85caca4a69c16be49..fbc268287ba218facd86246784c5ed226ac2dcf2 100644
3+
--- a/index.js
4+
+++ b/index.js
5+
@@ -47,7 +47,7 @@ function checkForProptypes(path, paramTypeName) {
6+
}
7+
8+
function setParamsTypeDefinitionFromFunctionType(documentation, path) {
9+
- if (path.parentPath.node.init && path.parentPath.node.init.params.length === 0) {
10+
+ if (path.parentPath.node.init && Array.isArray(path.parentPath.node.init.params) && path.parentPath.node.init.params.length === 0) {
11+
return;
12+
}
13+

pnpm-lock.yaml

Lines changed: 8 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/postinstall.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@ fi
1515

1616
echo "Running prettier on package.json files"
1717
# We need to run prettier to avoid unnecessary formatting changes to package.json (due to pnpm install).
18-
pnpm prettier --write --parser json '**/package.json' &>/dev/null
19-
20-
echo "Patching packages"
21-
pnpm patch-package
18+
pnpm prettier --write --parser json '**/package.json' &>/dev/null

0 commit comments

Comments
 (0)