Skip to content

[BUG] dependency sort order has changed slightly #3935

Description

@G-Rath

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Given the following package.json:

{
  "name": "spj-te",
  "dependencies": {
    "sort-package-json": "^1.52.0"
  },
  "devDependencies": {
    "@types/koa-bodyparser": "^4.3.3",
    "@types/koa__router": "^8.0.8"
  }
}

Running:

npm install sort-package-json

Gives:

{
  "name": "spj-te",
  "dependencies": {
    "sort-package-json": "^1.52.0"
  },
  "devDependencies": {
    "@types/koa__router": "^8.0.8",
    "@types/koa-bodyparser": "^4.3.3"
  }
}

Expected Behavior

I'd expect the package.json not to have changed.

This expected sort ordering is what appears to currently be used by:

  • npm v6
  • yarn v1 & v2
  • pnpm v6
  • sort-package-json

Obviously this is a cosmetic bug and (afaik) there isn't a defined standard on the order that should be used in the ecosystem, but given it looks like just npm v7/8 is the odd duck I figured I'd open an issue to see if folks would be open to a PR, as it makes for noisy diffs to have packages swap back and forward 😅

I'm happy to help do the work - I suspect based on #1766 it could be a matter of adjusting the code added in this commit having looked a bit more into this, it looks like this commits function has gone away so would appreciate being pointed in the right direction

Steps To Reproduce

See Current Behaviour

Environment

  • OS: Ubuntu 18.04
  • Node: 16.0.0
  • npm: v8 (latest, via npx), and v7 (latest, via npx)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions