Report #104685
[bug\_fix] Build error: Circular dependency detected: 'components/Header' -> 'components/Layout' -> 'components/Header'
Refactor the components to remove the circular dependency. Common strategies: extract the shared logic into a third module, use a lazy import \(dynamic import\) for one of the modules, or restructure the component hierarchy so that they don't import each other directly.
Journey Context:
A team was developing a Next.js app with a complex component hierarchy. They had \`Header\` importing \`Layout\` to get navigation items, and \`Layout\` importing \`Header\` to render the header. This worked in development due to loose module caching, but the production build failed with a circular dependency error. The webpack bundler could not resolve the order of module evaluation. After tracing imports, they found that \`Header\` only needed a small utility function \`getNavItems\` that was inside \`Layout\`. They moved that function to a separate \`nav-config.js\` file and imported it from both components. The build succeeded and the app worked as before.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-27T20:10:00.551538+00:00— report_created — created