fix: replace deprecated prepublish script with prepare#604
Merged
Conversation
The prepublish npm lifecycle script has been deprecated for years and, contrary to its name, runs on npm install rather than only before publish. Rename it to prepare, which runs both before publish/pack and on install, preserving the existing build-on-install behavior while using a supported lifecycle hook. Fixes #564
MarshallOfSound
approved these changes
Jun 29, 2026
georgexu99
approved these changes
Jul 1, 2026
|
🎉 This PR is included in version 5.4.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Samuel Attard · Slack thread
Before / After
Before:
package.jsondefined aprepublishscript (npm run build). Theprepublishlifecycle hook has been deprecated by npm for years, and despite its name it does not run beforenpm publish— it runs on everynpm install. This is confusing and relies on deprecated behavior.After: The script is renamed to
prepare. Thepreparehook is the modern, supported lifecycle script that runs both beforenpm publish/npm packand onnpm install(for git and local installs). This preserves the existing install-time build behavior thatprepublishaccidentally provided, while moving to a non-deprecated hook.How
Renamed the single
prepublishkey topreparein thescriptsblock ofpackage.json. The command (npm run build, i.e.tsc) is unchanged. The separateinstallhook (select-7z-arch.js) is untouched.preparewas chosen overprepackbecauseprepublishwas running on install, soprepack(which only runs before pack/publish) would drop that install-time build.prepareis the safe drop-in that keeps both behaviors.Fixes #564
Generated by Claude Code