Skip to content

Bundler Error while importing WorkflowChatTransportΒ #709

@avi1989

Description

@avi1989

After upgrading the workflow and @workflow/ai packages to 4.0.1-beta.39, I am unable to import WorkflowChatTransport in any client component. It looks like nextjs is trying to bundle @workflow/core into a client bundle.

This can be reproduced in vercel/workflow-examples by upgrading the package versions and running the pnpm dev on the flight booking app as I did here

The full error is below.

## Error Type
Build Error

## Error Message
Code generation for chunk item errored

## Build Output
./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/runtime/world.js
Code generation for chunk item errored
An error occurred while generating the chunk item [project]/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/runtime/world.js [app-client] (ecmascript)

Caused by:
- the chunking context (unknown) does not support external modules (request: node:module)

Debug info:
- An error occurred while generating the chunk item [project]/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/runtime/world.js [app-client] (ecmascript)
- Execution of <ModuleChunkItem as EcmascriptChunkItem>::content_with_async_module_info failed
- Execution of *EcmascriptChunkItemContent::new failed
- Execution of EcmascriptModuleContent::new failed
- the chunking context (unknown) does not support external modules (request: node:module)

Import traces:
  Client Component Browser:
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/runtime/world.js [Client Component Browser]
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/serialization.js [Client Component Browser]
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/step/writable-stream.js [Client Component Browser]
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/index.js [Client Component Browser]
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@aws-sdk+client_9829537cd50594c6b8f43bea9dee5ca1/node_modules/@workflow/ai/dist/agent/durable-agent.js [Client Component Browser]
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@aws-sdk+client_9829537cd50594c6b8f43bea9dee5ca1/node_modules/@workflow/ai/dist/index.js [Client Component Browser]
    ./app/page.tsx [Client Component Browser]
    ./app/page.tsx [Server Component]

  Client Component SSR:
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/runtime/world.js [Client Component SSR]
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/serialization.js [Client Component SSR]
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/step/writable-stream.js [Client Component SSR]
    ./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@workflow/core/dist/index.js [Client Component SSR]
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@aws-sdk+client_9829537cd50594c6b8f43bea9dee5ca1/node_modules/@workflow/ai/dist/agent/durable-agent.js [Client Component SSR]
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@aws-sdk+client_9829537cd50594c6b8f43bea9dee5ca1/node_modules/@workflow/ai/dist/index.js [Client Component SSR]
    ./app/page.tsx [Client Component SSR]
    ./app/page.tsx [Server Component]

Next.js version: 16.0.10 (Turbopack)

Additional Info
Adding

  experimental: {
    optimizePackageImports: ['@workflow/ai'],
  },
}

to next.config.ts makes the app work.

Metadata

Metadata

Assignees

No one assigned

    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