fix: handle unparseable @container conditions with error_recovery - #1330
Open
Larslllllll wants to merge 1 commit into
Open
fix: handle unparseable @container conditions with error_recovery#1330Larslllllll wants to merge 1 commit into
Larslllllll wants to merge 1 commit into
Conversation
…enabled
When parsing `@container scroll-content { ... }` (named container query with
no condition), the parser would fail with "Unexpected end of input" because
the `{` token is not a valid container condition.
With error_recovery enabled (used by Turbopack), the parser should use
ContainerCondition::Unknown for unparseable conditions instead of propagating
the error, allowing the CSS to be processed despite unsupported syntax.
Fixes a build failure in Turbopack when processing CSS containing
`@container <name> { ... }` with named container queries.
Member
|
We should probably fix the actual parser instead of relying on error recovery |
Contributor
Yes, since I last updated the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When parsing
@container <name> { ... }(named container query with no condition), the lightningcss parser fails with "Unexpected end of input" because the{token is not recognized as a valid container condition.This affects Turbopack (used by Next.js) which uses
error_recovery: truein its CSS parsing configuration.Root Cause
In
src/parser.rs, the@containercase has this error handling:When
input.is_exhausted()is false (i.e., there's a{token waiting), it returns an error instead of checkingerror_recovery.Fix
Check
self.options.error_recoverybefore returning the error. When error recovery is enabled, useContainerCondition::Unknownfor unparseable conditions:Testing
The fix allows CSS like this to be parsed without error:
This CSS is generated by real-world libraries like
nhsuk-frontend.