Turbopack build fails to parse valid CSS: named scroll-state container query
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/cptiv2020/turbopack-parsing-issue-repro
To Reproduce
- npx create-next-app@latest (App Router, default Turbopack build)
- Add a repro.css file containing the snippet and import it in page.tsx:
@supports (container-type: inline-size scroll-state) {
@container scroll-content {
.foo {
max-width: 100cqw;
}
}
}
- Run pnpm build / next build
Current vs. Expected behavior
Turbopack's CSS parser fails with Parsing CSS source code failed / Unexpected end of input on the named container query @container scroll-content { ... }. This is valid CSS per the CSS Containment Module Level 3 spec (named containers + scroll-state container queries) and is emitted by real-world libraries, e.g. nhsuk-frontend@10.6.1's compiled CSS:
./node_modules/nhsuk-frontend/dist/nhsuk/nhsuk-frontend.css:8545:29
Error: Parsing CSS source code failed
8543 | }
8544 | @supports (container-type: inline-size scroll-state) {
> 8545 | @container scroll-content {
| ^
8546 | .nhsuk-scroll .nhsuk-table__caption {
8547 | max-width: 100cqw;
8548 | }
Unexpected end of input
Expected: the build should succeed, treating the named @container rule the same as an unnamed one (@container (min-width: ...) { ... }), which parses fine.
I also pasted the full nhsuk-frontend.css file into the LightningCSS Playground directly and it parsed/transformed without any errors, which suggests the issue is in how Turbopack invokes/configures lightningcss (e.g. targets or draft/feature flags for container queries) rather than in lightningcss itself.
I believe they added support for it in version: https://github.com/parcel-bundler/lightningcss/releases#release-v1.31.0
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.6.0: Fri Jul 31 19:17:26 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6041
Available memory (MB): 49152
Available CPU cores: 12
Binaries:
Node: 24.20.0
npm: 11.19.0
Yarn: N/A
pnpm: 11.25.0
Relevant Packages:
next: 16.3.4 // Latest available version is detected (16.3.4).
eslint-config-next: N/A
react: 19.2.8
react-dom: 19.2.8
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack, CSS
Which stage(s) are affected? (Select all that apply)
next build (local), next dev (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction, the repro.css snippet, and page.tsx, then run pnpm build or next build to confirm the failure. Trace Turbopack's CSS parsing and LightningCSS version or feature configuration. Done means the named scroll-state @container rule parses successfully in next build and next dev, as the unnamed form already does.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, javascript, next.js
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100