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
Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
The bug seems to occur when removing a package dependency when it is the last dependency for that JSON key. Instead of removing the section and leaving the rest of the package.json file intact, it completely reformats the entire file, re-arranging the top-level keys in a seemingly random order.
I'm generally in favor of normalizing the formatting in JSON files, but package.json is one exception. I want to keep important information, including scripts, near the top.
I haven't encountered this behavior with any other package managers (npm, yarn, pnpm).
Run bun install for the initial installation of packages.
Run bun remove is-number.
What is the expected behavior?
Since there are no remaining packages under dependencies, I expect that section to be removed without affecting any other sections or top-level key ordering.
The example I gave is fairly small. The reformatting is more disconcerting with a larger package.json file that has many devDependencies entries but maybe only one dependencies entry that needs removed (for example).
I mostly run into this when I have a project with zero dependencies entries and I accidentally add a new package as a regular dependency instead of a dev dependency, then remove it. Or vice versa.
The text was updated successfully, but these errors were encountered:
What version of Bun is running?
1.0.30+1424a196f
What platform is your computer?
Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
The bug seems to occur when removing a package dependency when it is the last dependency for that JSON key. Instead of removing the section and leaving the rest of the
package.json
file intact, it completely reformats the entire file, re-arranging the top-level keys in a seemingly random order.I'm generally in favor of normalizing the formatting in JSON files, but
package.json
is one exception. I want to keep important information, includingscripts
, near the top.I haven't encountered this behavior with any other package managers (
npm
,yarn
,pnpm
).package.json
contents:bun install
for the initial installation of packages.bun remove is-number
.What is the expected behavior?
Since there are no remaining packages under
dependencies
, I expect that section to be removed without affecting any other sections or top-level key ordering.What do you see instead?
The top-level keys are re-ordered.
Additional information
The example I gave is fairly small. The reformatting is more disconcerting with a larger
package.json
file that has manydevDependencies
entries but maybe only onedependencies
entry that needs removed (for example).I mostly run into this when I have a project with zero
dependencies
entries and I accidentally add a new package as a regular dependency instead of a dev dependency, then remove it. Or vice versa.The text was updated successfully, but these errors were encountered: