oven-sh / bun

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

Upgrade of "next" package does not seem to update "@next/swc" optional dependency #8726

Open raphaelsaunier opened 8 months ago

raphaelsaunier commented 8 months ago

What version of Bun is running?

1.0.25+a8ff7be64

What platform is your computer?

Darwin 23.3.0 x86_64 i386

What steps can reproduce the bug?

  1. Create a next.js project with npx create-next-app@latest
  2. Upgrade next version (e.g. from 14.0 -> 14.1, or from 14.1 to 14.1.1-canary.36) in package.json
  3. Run bun install

What is the expected behavior?

Next.js and its @next/swc_{platform} optional (peer?) dependency should both be updated to the specified version.

What do you see instead?

Next.js is correctly updated but @next/swc isn't and triggers a warning when running bun run dev or bun run build.

 ⚠ Mismatching @next/swc version, detected: 14.0.1 while Next.js is on 14.1.1-canary.36. Please ensure these match

Additional information

Workaround: yarn install once to fetch/link the correct package and the warning disappears.

Also, running bun pm cache rm does not solve the issue.

noejunior792 commented 1 month ago

I'm having the same error, on Windows 11, with Next.js 14.

raphaelsaunier commented 1 month ago

Yup, I just upgraded to Bun v1.1.27 and I can confirm that the issue still persists.

In the example below, it occurs after upgrading from Next 14.2.3 to 14.2.9:

$ bun i
[0.07ms] ".env"
bun install v1.1.27 (267afa29)

+ next@14.2.9

5 packages installed [3.70s]

$ bun run dev

  ▲ Next.js 14.2.9
  - Local:        http://localhost:3000
  - Environments: .env.development, .env
  - Experiments (use with caution):
    · instrumentationHook

 ✓ Starting...
 ⚠ Mismatching @next/swc version, detected: 14.2.3 while Next.js is on 14.2.9. Please ensure these match
[…]
 ⨯ ./src/instrumentation.ts
Error: unknown field `hashSalt`, expected `isReactServerLayer` or `enabled` at line 1 column 1109
Error: An error occurred while loading instrumentation hook: Cannot find module '/path/to/project/.next/server/instrumentation'
Require stack:
- /path/to/project/node_modules/next/dist/server/dev/next-dev-server.js
- /path/to/project/node_modules/next/dist/server/next.js
- /path/to/project/node_modules/next/dist/server/lib/start-server.js