Skip to content

Nextjs package breaks with turbopack #3607

@sonyatalona

Description

@sonyatalona

hey team, noticed an interesting behaviour around nextjs, turbopack build, and @rivetkit/next-js (v 2.0.25) (yes, a weird connection).

I think what happens is that tsup bundles test files and some of the test packages/helpers are not very well supported by turbopack, thus it breaks. Resolution is to swap you build script to be like

"build": "next build --webpack",

however, it's a very top level patch that might not be an option for you.

Error: Turbopack build failed with 40 errors:
./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/ts.test.ts
Missing module type
The module type effect must be applied before adding Ecmascript transforms


...

Import trace:
  App Route:
    ./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/thread-management.test.js
    ./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/index.js
    ./node_modules/.pnpm/pino@9.14.0/node_modules/pino/lib/transport.js
    ./node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js
    ./node_modules/.pnpm/rivetkit@2.0.25_@standard-schema+spec@1.0.0_ws@8.18.3/node_modules/rivetkit/dist/tsup/chunk-HK2X2UOP.js
    ./node_modules/.pnpm/@rivetkit+next-js@2.0.25_@standard-schema+spec@1.0.0_react-dom@19.2.1_react@19.2.1__react@19.2.1_ws@8.18.3/node_modules/@rivetkit/next-js/dist/mod.mjs
    ./src/app/api/rivet/[...all]/route.ts

https://nextjs.org/docs/messages/module-not-found


./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/thread-management.test.js:13:17
Module not found: Can't resolve '/ROOT/node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/create-and-exit.js'
  11 | test('exits with 0', async function (t) {
  12 |   const dest = file()
> 13 |   const child = fork(join(__dirname, 'create-and-exit.js'), [dest])
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  14 |
  15 |   const [code] = await once(child, 'exit')
  16 |   t.equal(code, 0)



Import trace:
  App Route:
    ./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/thread-management.test.js
    ./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/index.js
    ./node_modules/.pnpm/pino@9.14.0/node_modules/pino/lib/transport.js
    ./node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js
    ./node_modules/.pnpm/rivetkit@2.0.25_@standard-schema+spec@1.0.0_ws@8.18.3/node_modules/rivetkit/dist/tsup/chunk-HK2X2UOP.js
    ./node_modules/.pnpm/@rivetkit+next-js@2.0.25_@standard-schema+spec@1.0.0_react-dom@19.2.1_react@19.2.1__react@19.2.1_ws@8.18.3/node_modules/@rivetkit/next-js/dist/mod.mjs
    ./src/app/api/rivet/[...all]/route.ts

https://nextjs.org/docs/messages/module-not-found


./node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/test/esm.test.mjs:4:1
Module not found: Can't resolve 'desm'
  2 | import { readFile } from 'fs'
  3 | import ThreadStream from '../index.js'
> 4 | import { join } from 'desm'
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5 | import { pathToFileURL } from 'url'
  6 | import { file } from './helper.js'
  7 |

(there is a lot more im not pasting as part of logs)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions