Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependencies sorting in generated package.json causes unnecessary git diffs #77679

Open
diegomais opened this issue Apr 1, 2025 · 0 comments
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application.

Comments

@diegomais
Copy link

Link to the code that reproduces this issue

https://github.com/diegomais/nextjs-issue-reproduction

To Reproduce

  1. Create a new project by running: npx create-next-app@latest --use-pnpm
  2. Add a new dependency by running: pnpm add @radix-ui/react-popover
  3. Package managers would reorder dependencies in package.json after installation, causing unnecessary git diffs

Current vs. Expected behavior

I expected to create-next-app to generate pre-sorted dependencies and devDependencies in package.json file, but I observed package managers sorting them after adding a new dependency and devDependency in package.json.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 15.2.4 // Latest available version is detected (15.2.4).
  eslint-config-next: 15.2.4
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

create-next-app

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

This change improves the consistency of generated package.json files and makes them more predictable across different package managers. It's a small but useful improvement for maintainability and readability.

This was problematic because:

  • It created noise in git history
  • Made it harder to review actual dependency changes
  • Caused unnecessary merge conflicts
  • Required manual sorting to maintain consistency

PR #77396 solves this issue.

@github-actions github-actions bot added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label Apr 1, 2025
@diegomais diegomais changed the title Dependencies Sorting in Generated package.json Causes Unnecessary Git Diffs Dependencies sorting in generated package.json causes unnecessary git diffs Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application.
Projects
None yet
Development

No branches or pull requests

1 participant