oven-sh / bun

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

Support Next.js 13 in Bun #3776

Closed Jarred-Sumner closed 5 months ago

Jarred-Sumner commented 1 year ago

Known major blockers:

The first issue is here:

17 | class NotImplementedError extends Error {
18 |   code;
19 |   constructor(feature, issue) {
20 |
21 |     super(feature + " is not yet implemented in Bun." + (issue ? " Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/" + issue : ""));
       ^
NotImplementedError: node:diagnostics_channel is not yet implemented in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/2688
 code: "ERR_NOT_IMPLEMENTED"

      at new NotImplementedError (node:diagnostics_channel:21:4)
      at throwNotImplemented (node:diagnostics_channel:8:8)
      at channel (node:diagnostics_channel:30:2)
      at 4822 (/Users/jarred/Build/nexty/node_modules/next/dist/compiled/undici/index.js:2:163873)
      at __nccwpck_require__ (/Users/jarred/Build/nexty/node_modules/next/dist/compiled/undici/index.js:3:13952)
      at 4475 (/Users/jarred/Build/nexty/node_modules/next/dist/compiled/undici/index.js:3:6547)
      at __nccwpck_require__ (/Users/jarred/Build/nexty/node_modules/next/dist/compiled/undici/index.js:3:13952)
      at 9002 (/Users/jarred/Build/nexty/node_modules/next/dist/compiled/undici/index.js:1:27356)
      at __nccwpck_require__ (/Users/jarred/Build/nexty/node_modules/next/dist/compiled/undici/index.js:3:13952)
      at /Users/jarred/Build/nexty/node_modules/next/dist/compiled/undici/index.js:3:14201

Bun has a builtin polyfill for "undici" which uses the globals for fetch, Request, etc instead of a JS implementation. When run in Bun, next should use that. The same for "ws".

Jarred-Sumner commented 1 year ago

cc @timneutkens @leerob

controversial commented 5 months ago

Congrats to the Bun team on shipping this! :‍)

Note that that running bun --bun next dev still errors for apps using middleware, blocked on #5648 (see #9447)

kapitche commented 5 months ago

Congrats to the Bun team on shipping this! :‍)

Note that that running bun --bun next dev still errors for apps using middleware, blocked on #5648 (see #9447)

Indeed been trying to push this issue for months because otherwise bun is not production ready to work with under nextjs14

ebidel commented 5 months ago

Anyone else seeing high CPU usage when running the next dev server with bun --bun next dev? This is refreshing the page a few times:

Screenshot 2024-04-03 at 3 02 44 PM
kapitche commented 5 months ago

Anyone else seeing high CPU usage when running the next dev server with bun --bun next dev? This is refreshing the page a few times:

Screenshot 2024-04-03 at 3 02 44 PM

Personally I can't even run it because am I using nextjs 14 middleware