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

Turbopack Dynamic Worker Path Includes TypeScript Declaration Files Causing Build Failure

When a dynamic new Worker() path is used, Turbopack expands the directory context to include all files, including .d.ts, .d.cts, and .d.mts declaration files, which cannot be loaded at runtime. This leads to 'Unknown module type' or module format mismatch errors and breaks builds.

highConfidence 85%Next.jsPages RouterReact Server ComponentsServer ActionsAffected V16.3.7Affected V16.4.0-Canary.52

Origin Analysis

Turbopack's dynamic import/worker asset resolution lacks filtering for TypeScript declaration files, which are type-only and never valid runtime modules. The context module expansion treats them as runtime assets and attempts to compile them, failing because they have no associated runtime module type.
1. Clone https://github.com/orleib-lab/turbopack-dcts-worker-repro\n2. Run npm install\n3. Run npm run build\n4. Build fails with error on node_modules/worker-pkg/dist/index.d.cts

Fixing Code Block

Edge Case Audit

This change should be safe as declaration files cannot be executed at runtime; however, any tooling that relied on Turbopack mistakenly including them would break (none expected). Rollback: revert the filtering patch. Additionally, ensure the filter is applied consistently in both bundled and external tracing paths to avoid divergent behavior.

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