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

Turbopack Fails To Evaluate Variable-Assigned Default Exports In Postcss.Config.Mjs

Next.js development server with Turbopack throws 'PostCSS config is undefined' when postcss.config.mjs uses a variable for the default export, even though the module is valid ESM. Direct object literal export works as a workaround.

highConfidence 92%Next.jsRoute HandlersHydrationAffected V16.3.0

Origin Analysis

Turbopack's PostCSS configuration loader only recognizes inline ObjectExpression or FunctionExpression in the ExportDefaultDeclaration. When the default export is an Identifier referencing a previously declared variable, the evaluator fails to resolve the binding and returns undefined.
1. Create a Next.js 16.3.0 project with postcss.config.mjs containing: ```javascript const config = { plugins: { "@tailwindcss/postcss": {}, }, }; export default config; ``` 2. Run `next dev`. 3. Observe terminal error: `Error: PostCSS config is undefined (make sure to export an function or object from config file)` when loading `globals.css`.

Fixing Code Block

Edge Case Audit

This is a temporary workaround and does not fix the underlying Turbopack bug. It may reduce readability or reusability of the config object. After upgrading to a Next.js version that resolves the issue, consider reverting to the variable-based approach to maintain code clarity. No concurrency or multi-threading risks are introduced by this change; the only risk is potential merge conflicts if the file is later refactored to use variables again. Rollback: simply restore the previous `const config = {...}; export default config;` syntax.

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