Add preversion/postversion script for propagating versions in npm workspaces #5303
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.
Changelog Entry
(No changelog for build scripts update.)
Description
npm has limited workspace support on
npm version
.In a npm workspace, when running
npm version --workspaces 1.2.3
, npm does not update version numbers independencies
anddevDependencies
for local dependencies. That means, it could point to an outdated version and could also look for it on public registry.We are introducing
preversion
andpostversion
scripts that would remove local dependencies while runningnpm version
.As
npm version
by default would runnpm update
afterwards, after ourpostversion
restoring the local dependencies,npm update
should updatepackage-lock.json
and point to the right version inside the workspace.We prefer
preversion
andpostversion
as we can leveragenpm version
and lower learning curve.In the future, we should have a script at root-level to automatically generate the
localDependencies
in eachpackage.json
.Design
Updated
package.json/localDependencies
field for a single map for both development and production dependencies.bump
will bump non-local dependencies.preversion
/postversion
will temporarily remove local dependencies, runnpm version
, then restore local dependencies. By default,npm version
will also runnpm update
automatically to link the newer version number inpackage-lock.json
.Specific Changes
package.json
preversion
andpostversion
script to temporarily remove local dependencies fromdependencies
anddevDependencies
localPeerDependencies
/localPeerDevDependencies
array tolocalDependencies
map for consolidationbump
script for the newlocalDependencies
I have added tests and executed them locallyI have updatedCHANGELOG.md
I have updated documentationReview Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)Browser and platform compatibilities reviewedCSS styles reviewed (minimal rules, noz-index
)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.json
andpackage-lock.json
reviewedSecurity reviewed (no data URIs, check for nonce leak)Tests reviewed (coverage, legitimacy)