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

Turbopack Fails To Parse Named Scroll-State Container Queries Due To Outdated Lightningcss

Next.js build with Turbopack fails when encountering a named @container rule (e.g., @container scroll-content) that does not include a condition, because the bundled lightningcss version lacks support for named container queries (scroll-state). This causes 'Unexpected end of input' errors during CSS parsing, breaking builds for projects that rely on such CSS (e.g., nhsuk-frontend).

highConfidence 95%Next.jsAffected V16.3.4

Origin Analysis

Turbopack's CSS parser uses an outdated version of lightningcss (pre v1.31.0) that does not support named container queries introduced in CSS Containment Module Level 3. The parser expects a condition after the container name, so when it encounters a bare name like `scroll-content`, it misinterprets the syntax and reaches an unexpected end of input. Lightningcss v1.31.0 added support for named scroll-state container queries, so upgrading to that version (or later) resolves the parse error.
1. Create a Next.js app with Turbopack (default). 2. Add a CSS file containing: `@supports (container-type: inline-size scroll-state) { @container scroll-content { .foo { max-width: 100cqw; } } }`. 3. Import the CSS in a page and run `next build`. Observe the build fails with 'Parsing CSS source code failed / Unexpected end of input'.

Fixing Code Block

Edge Case Audit

Ensure that the lightningcss crate upgrade is thoroughly tested with existing CSS features used by Next.js applications. Check for any breaking changes in lightningcss v1.31.0 (unlikely for parsing). Validate with a variety of CSS files, including those with older container query syntax and preprocessor outputs. In case of regression, revert to previous version and disable scroll-state container query usage.

Ecosystem Topology