-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Describe the bug
When using @workflow/world-postgres with the Next.js App Router, the development server crashes with an ERR_REQUIRE_ESM error upon the first API request to a route that uses the workflow library.
Maybe the error occurs because @workflow/world-postgres is an ES Module ("type": "module"), but some part of the Next.js build process (seemingly triggered by the workflow library's internal runtime) attempts to load it using require()?
To Reproduce
- Create a Next.js App Router project.
- Install the following packages:
next:15.3.5workflow:4.0.1-beta.11@workflow/world-postgres:4.1.0-beta.7
- Set up a simple API route (
/api/test/route.ts) that importsstartfromworkflow/api. - Configure
instrumentation.tsto initialize the postgres world. - Run the development server (
next dev) and send a POST request to the API route.
Expected behavior
The API route should execute the workflow without crashing the server.
Error Log
Error: require() of ES Module /path/to/project/node_modules/.pnpm/@[email protected]/.../node_modules/@workflow/world-postgres/dist/index.js from /path/to/project/apps/api2/index.js not supported.
Instead change the require of ... to a dynamic import() which is available in all CommonJS modules.
at createWorld (../../src/runtime/world.ts:47:14)
at getWorldHandlers (../../src/runtime/world.ts:74:17)
...
Metadata
Metadata
Assignees
Labels
No labels