You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have standards for our package.json files in our monorepo. We have a tool that executes on postinstall to patch up any accidental omissions or alert the dev to the issues.
For legibility, we sort certain fields (dependencies, devDependencies, peerDependencies), and we insert blank lines to separate certain entries in the scripts hash (to organize them into groups of related commands), and we inject some helper scripts.
This worked great until we switched to yarn-berry, but now our postinstall script only executes when a module was changed, but if the dev calls yarn again the package.json suddenly gets reformatted (first discovered on 3.6.4, but still happens on 4.6.0).
Searching found a similar issue: #6282 -- unfortunately, while the title matches my concerns, it was marked as a duplicate of a different, more narrow issue: #6184
The issue I'm filing here demonstrates that the problem is nothing as narrow as something related to a single field, but rather affects package.json more widely.
Please let me know if as a workaround I could hook our formatting/fixup-tool into a different lifecycle script? I couldn't find any that were called in this situation (appropriate or not).
My assertion: yarn shouldn't change package.json unless there was a functional configuration issue (eg. inserting a missing required field). -- If this assertion is incorrect, please do explain.
The text was updated successfully, but these errors were encountered:
Self-service
Describe the bug
We have standards for our package.json files in our monorepo. We have a tool that executes on
postinstall
to patch up any accidental omissions or alert the dev to the issues.For legibility, we sort certain fields (
dependencies
,devDependencies
,peerDependencies
), and we insert blank lines to separate certain entries in the scripts hash (to organize them into groups of related commands), and we inject some helper scripts.This worked great until we switched to yarn-berry, but now our
postinstall
script only executes when a module was changed, but if the dev callsyarn
again thepackage.json
suddenly gets reformatted (first discovered on 3.6.4, but still happens on 4.6.0).To reproduce
Notice the unexpected loss of the newline between "meep" and "moop"
Environment
System: OS: macOS 15.1.1 CPU: (10) arm64 Apple M1 Max Binaries: Node: 23.6.0 - /private/var/folders/01/4rfqmhmn03s0vby9xw8cz6qr0000gp/T/xfs-da12c7f8/node Yarn: 4.6.0 - /private/var/folders/01/4rfqmhmn03s0vby9xw8cz6qr0000gp/T/xfs-da12c7f8/yarn npm: 10.9.2 - ~/.nvm/versions/node/v23.6.0/bin/npm
Additional context
Searching found a similar issue: #6282 -- unfortunately, while the title matches my concerns, it was marked as a duplicate of a different, more narrow issue: #6184
The issue I'm filing here demonstrates that the problem is nothing as narrow as something related to a single field, but rather affects
package.json
more widely.Please let me know if as a workaround I could hook our formatting/fixup-tool into a different lifecycle script? I couldn't find any that were called in this situation (appropriate or not).
My assertion:
yarn
shouldn't changepackage.json
unless there was a functional configuration issue (eg. inserting a missing required field). -- If this assertion is incorrect, please do explain.The text was updated successfully, but these errors were encountered: