Skip to content

fix: move patch-package to dependencies for consumer installs#465

Closed
jaieds wants to merge 1 commit into
masterfrom
fix/patch-package-consumer-install
Closed

fix: move patch-package to dependencies for consumer installs#465
jaieds wants to merge 1 commit into
masterfrom
fix/patch-package-consumer-install

Conversation

@jaieds

@jaieds jaieds commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Installing @bsf/force-ui v1.7.12 as a git dependency (e.g. in SureRank) fails:

npm error command sh -c patch-package
npm error sh: patch-package: command not found

v1.7.12 added "postinstall": "patch-package" for the Lexical Shadow DOM patches, but patch-package is only in devDependencies. npm runs a dependency's own postinstall during consumer installs, and devDependencies aren't installed for consumers — exit 127.

Why not just remove the postinstall

The Lexical patches are runtime-critical (Shadow DOM selection/typeahead support patched into lexical core), and the Vite build externalizes all lexical/@lexical/* packages — consumers install their own lexical 0.38.2 from the registry. Without patch-package running in the host project, consumers get unpatched lexical and the Shadow DOM mention fix from v1.7.12 silently doesn't work.

Fix

Move patch-package from devDependencies to dependencies (the standard pattern for libraries shipping patches). Consumer installs then have the binary available, and patch-package applies the patches/ to the host's hoisted lexical.

Release note

The 1.7.12 release tag's committed package.json also carries the broken combination — after this merges, the tag needs re-creating (or ship 1.7.13) so git-dep consumers pick up the fix.

The postinstall script (patch-package) runs when consumers install
@bsf/force-ui as a git dependency, but patch-package was only in
devDependencies, so consumer installs failed with:

    sh: patch-package: command not found (exit 127)

Moving it to dependencies fixes the install and also ensures the
Lexical Shadow DOM patches get applied to the host project's
node_modules — required at runtime because the build externalizes
lexical, so consumers would otherwise run unpatched lexical and the
Shadow DOM mention fix would silently not work.
Comment thread package-lock.json
@@ -24,6 +24,7 @@
"lexical": "0.38.2",
"lucide-react": "^0.417.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What: Ensure that patch-package is included in the main dependencies rather than in devDependencies. Moving it is correct, but keep an eye on the consistency of this throughout the project. Sometimes libraries that need to be used at runtime are mistakenly placed in separate sections.

Why: Including patch-package as a dependency is crucial since consumers of the code require it for applying patches at install time. This change aligns with typical library behaviors and ensures that critical patches are applied without requiring consumers to have knowledge of setup.

How: Verify that any existing usage of patch-package in your codebase or documentation reflects this change. Clear documentation will greatly assist consumers, especially those who may refer to the usage guides or setup instructions.

@jaieds

jaieds commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #466, which targets staging per release flow and includes the complete fix — verification showed moving patch-package to dependencies alone didn't get the Lexical patches applied in consumer projects.

@jaieds jaieds closed this Jun 11, 2026
@jaieds jaieds deleted the fix/patch-package-consumer-install branch June 11, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant