AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack: Build Failure When Using Dynamic Imports And Cache Components

Next.js 16.3.0-canary.40 with Turbopack fails to build when a dynamic import is combined with cacheComponents, while webpack succeeds. The issue is caused by Turbopack's dynamic import handling not correctly processing cacheComponents directives, leading to module resolution errors.

highConfidence 65%Next.jsRoute Handlersnext buildAffected V16.3.0-Canary.40

Origin Analysis

Turbopack's dynamic import transformation does not account for cacheComponents metadata, causing the generated client boundary to bypass the necessary server component registration, resulting in a build-time failure.
1. Clone the repository https://github.com/ozavodny/turbopack-dynamic-repro\n2. Run `npm install`\n3. Run `npm run build`\n4. Observe the build failure with Turbopack; switching to webpack (e.g., `npm run build -- --webpack`) succeeds.

Fixing Code Block

Edge Case Audit

This patch modifies Turbopack internals and may affect other dynamic import scenarios. Testing should include combinations of dynamic imports with and without cacheComponents, SSR, and client navigation. If regressions occur, rollback this patch and temporarily use webpack (`--webpack` flag) as a workaround.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state