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

Non-Deterministic Build Output Due To Unordered CSS Module Processing

Next.js builds produce different file hashes for the same source code, caused by non-deterministic ordering of CSS modules during webpack compilation, affecting static export reproducibility.

highConfidence 68%Next.jsAffected V13.4.10Affected V14.2.0-Canary.17

Origin Analysis

The App Router's CSS module loader processes imports in an order influenced by asynchronous filesystem operations, leading to varying chunk content and hashes. This is a design flaw in Next.js's webpack integration where the CSS module import array is not sorted before generating the client reference code.
1. Clone the reproduction repo or create a minimal Next.js app with App Router and CSS modules. 2. Run `next build` with `output: 'export'`. 3. Save the output and run `next build` again. 4. Compare file hashes in `out/_next/static/chunks/app/`; observe differing `layout-*.js` files.

Fixing Code Block

Edge Case Audit

This patch modifies Next.js internals and may not be compatible with future versions. Test extensively, especially with CSS Modules, global CSS, and CSS-in-JS. Rollback by reverting the patch or removing the custom plugin. For Next.js upgrades, reapply patch if still needed.

Ecosystem Topology