oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.32k stars 2.78k forks source link

Bun reinstalls dependencies with `11.0.0-rc.485` style semver on every install #13563

Closed Vinlock closed 2 months ago

Vinlock commented 2 months ago

What version of Bun is running?

1.1.26+0a37423ba

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

Add these dependencies to your package.json.

{
  "name": "bun-test",
  "module": "index.ts",
  "type": "module",
  "dependencies": {
    "@trpc/client": "11.0.0-rc.485",
    "@trpc/react-query": "11.0.0-rc.485",
    "@trpc/server": "11.0.0-rc.485"
  },
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  }
}

Run bun i. Notice that it will install the dependencies.

Run bun i again. Notice it will install them again.

What is the expected behavior?

It should only install once and then when running bun i again it will not re-install them.

What do you see instead?

It continuously re-installs those 3 dependencies.

~/projects/bun-test
❯ bun i
bun install v1.1.26 (0a37423b)

+ @trpc/client@11.0.0-rc.485
+ @trpc/react-query@11.0.0-rc.485
+ @trpc/server@11.0.0-rc.485

10 packages installed [237.00ms]

~/projects/bun-test
❯ bun i
bun install v1.1.26 (0a37423b)

+ @trpc/client@11.0.0-rc.485
+ @trpc/react-query@11.0.0-rc.485
+ @trpc/server@11.0.0-rc.485

3 packages installed [31.00ms]

~/projects/bun-test
❯ bun i
bun install v1.1.26 (0a37423b)

+ @trpc/client@11.0.0-rc.485
+ @trpc/react-query@11.0.0-rc.485
+ @trpc/server@11.0.0-rc.485

3 packages installed [29.00ms]

Additional information

No response

dylan-conway commented 2 months ago

@trpc/(server/client/react-query) are published with version 11.0.0-rc.485, but the package.json in the tarball also includes a build tag in the version, 11.0.0-rc.485+1c1d824cd. This difference causes this bug because bun is byte comparing the expected version (version from root package.json) with the received version (version in node_modules/@trpc/client/package.json). Instead, we should order the version strings as semver, or exclude build tags from the byte comparison.