Repository navigation
fix(compiler): support lightningcss 1.30.2+ visitor deserialization - #605
Merged
danstepanov merged 2 commits intoDec 4, 2026
Merged
Conversation
sammoore
force-pushed
the
fix/lightningcss-1.30.2-visitors
branch
from
December 3, 2026 23:44
63d856a to
5cfc519
Compare
sammoore
marked this pull request as ready for review
December 3, 2026 23:44
Avoids returning StyleSheet from the first pass (returning only modified/removed declarations instead), strips null Option fields (parcel-bundler/lightningcss#1065, #1081), and rewrites out-of-range integer dimensions as raw dimension tokens (#1188). The loader's 1.30.2 check stays. Fixes nativewind#470.
…on tokens The second pass already converts a rem dimension token with inlineRem, so converting it to px before handing it back to lightningcss changes nothing. Removes the remMultiplier parameter threaded through foldDeclaration, sanitizeTokenList and unparseIndividualTransform. Output is identical on lightningcss 1.30.1 and 1.33.0 for 70000rem through var() and translate, with and without inlineRem.
danstepanov
force-pushed
the
fix/lightningcss-1.30.2-visitors
branch
from
December 4, 2026 03:32
5cfc519 to
ecac3a4
Compare
danstepanov
approved these changes
Dec 4, 2026
sammoore
added a commit
to sammoore/react-native-css
that referenced
this pull request
Dec 4, 2026
Since nativewind#605 returns nothing from the visitor for an untouched rule, lightningcss no longer round-trips it through its serializer, which wrote -0 as 0. The operand now keeps its sign. It compares as 0, and JSON writes it as 0 for a device, so nothing renders differently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sammoore
added a commit
to sammoore/react-native-css
that referenced
this pull request
Dec 4, 2026
Since nativewind#605 returns nothing from the visitor for an untouched rule, lightningcss no longer round-trips it through its serializer, which wrote -0 as 0. The operand now keeps its sign. It compares as 0, and JSON writes it as 0 for a device, so nothing renders differently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sammoore
added a commit
to sammoore/react-native-css
that referenced
this pull request
Dec 4, 2026
Since nativewind#605 returns nothing from the visitor for an untouched rule, lightningcss no longer round-trips it through its serializer, which wrote -0 as 0. The operand now keeps its sign. It compares as 0, and JSON writes it as 0 for a device, so nothing renders differently.
danstepanov
pushed a commit
that referenced
this pull request
Dec 4, 2026
…decide with unknown (#608) * fix: evaluate range pairs, and answer a condition the runtime cannot decide with unknown Media and container queries now evaluate through one walk and one comparison in three-valued logic (MQ5 §3.1): a term the runtime cannot decide is unknown, its negation too, and a rule applies only when its condition is true, as in Chromium, Firefox and WebKit. - A range pair is its two comparisons, where both runtimes answered it false. - A term is unknown when its feature is unmeasured, its value is outside the feature's syntax (a keyword or a type Media Queries 5 does not give it, env(), a negative resolution or ratio component) or its operand is unresolved, which compiles to null so JSON carries it. A condition the compiler's unknown terms leave no way to be true compiles to no rule, as does a container condition CSS Conditional 5 §5.4 discards. - A number past the largest float compiles to the largest safe integer and a length to the same bound rounded, since JSON writes Infinity as null. - A feature in a boolean context is false only for zero, none and no-preference. - A viewport length in a condition resolves against the window. - hover, any-hover, pointer and any-pointer answer for the primary input, as Safari and Chrome do on a phone; color, color-index, monochrome, grid, scripting, update, overflow-block, overflow-inline, scan, color-gamut, dynamic-range and their video- forms answer as every React Native screen does, forced-colors as none off Windows, and -webkit-device-pixel-ratio as resolution. - A keyword and a media type match in any case. - A compiled condition is readonly at every depth, and the condition compiler reads lightningcss's AST through DeepReadonly. * fix(native): keep main's answer to every hover comparison The PR answers hover for the primary input, none on a touchscreen, which drops Tailwind's hover:, group-hover: and peer-hover: wherever a hover does arrive on iOS or Android (an iPad trackpad, a component that calls onHoverIn), unlike Nativewind v4 and every v5 release. Leaving hover unanswered would be worse: under three-valued logic (hover: hover) would be unknown, and hover: would apply nowhere. What hover should answer is left for later, so this keeps main's placeholder unchanged: every (hover: ...) comparison holds. any-hover and hover's boolean context go unanswered, as no Tailwind variant writes them. pointer and any-pointer keep answering for the primary input. * refactor(native): drop media features no Tailwind variant reaches color, color-index, monochrome, grid, update, overflow-block, overflow-inline, scan, color-gamut, dynamic-range, their video- forms and -webkit-device-pixel-ratio go back to being unmeasured, and an <mq-boolean> compiles as before. No Tailwind variant queries any of them, so they are a feature of their own rather than part of evaluating a condition in three-valued logic. scripting and forced-colors stay: Tailwind's noscript: and forced-colors: reach them, and without an answer their not- forms would become unknown. * refactor(compiler): keep main's handling of non-finite numbers Drops safeNumber: a media number, resolution or calc() operand compiles as written again, and a length in a declaration keeps main's clamping. safeNumber changed stock Tailwind output (rounded-full's calc(infinity * 1px) went from 9007199254740991 to 9007199254740990) and covers only operands past the largest float, which no Tailwind variant writes. A viewport length lightningcss prints as an overflowing number, such as calc(NaN * 1vw), reaches a device as null and stays unknown, so its over-the-wire test row goes too. * refactor: drop the readonly condition types Removes DeepReadonly, ReadonlyStyleDescriptor and the readonly tuples in MediaCondition, RenderGuard and the condition walkers, with condition-types.test.ts, which only checked them. They change no emitted code; MediaFeatureOperand keeps the shape a condition operand has. The container guard keeps the PR's honest type for a missing container, which the lint the PR enables on this file requires. * refactor(native): represent an unknown condition as undefined A condition still takes three values, since not unknown must stay unknown rather than become true, but undefined carries the third as well as a string did, so the Truth type and the UNKNOWN constant go. * test(compiler): expect -0 from a -0dppx resolution Since #605 returns nothing from the visitor for an untouched rule, lightningcss no longer round-trips it through its serializer, which wrote -0 as 0. The operand now keeps its sign. It compares as 0, and JSON writes it as 0 for a device, so nothing renders differently. * test(tailwind): drop the hover platform setup main's answer makes moot With main's answer to every hover comparison kept, hover: and group-hover: apply whatever the platform, so the Mac Catalyst mock around those tests changed nothing, and the touchscreen tests repeated them on the iOS preset. The tests go back to main's layout, keeping the author's assertions that the colour is absent. The setup moves to the hover patch, where the platform decides the answer. --------- Co-authored-by: Yevhenii <evgeny.kotyrlo@gmail.com>
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.
Fixes #470.
The bug
Starting in
lightningcss@1.30.2(upstream commit9879b91, switching visitor buffering toserde-content), returning a node from a JS visitor triggers two deserialization regressions that remain unfixed in published releases through1.33.0:nullinOption<T>fields (parcel-bundler/lightningcss#1065,#1081): any unresolvedvar()arrives in JS withfrom: nullandfallback: null, so handing it back tolightningcssthrowsfailed to deserialize; expected an object-like struct named Specifier, found (). Anonymous@layerand unnamed@containerrules fail the same way.f32fields (parcel-bundler/lightningcss#1188): returning a parsedLengthValue/Angle/Time/Resolutionwhose value isInfinity(Tailwind v4's.rounded-full { border-radius: calc(infinity * 1px); }) or an integer outside[-32768, 65535](e.g.99999px) throwsexpected a 32-bit floating point, found inff64/99999i64.In
src/compiler/compiler.ts, the first pass'sStyleSheetExitreturned the entireStyleSheetAST (even wheninlineVariables: false), so every stylesheet with an unresolvedvar()(such as Tailwind 4's.border { border-style: var(--tw-border-style); }) or.rounded-fullcrashed onlightningcss >= 1.30.2. The loader inlightningcss-loader.tsonly blocked1.30.2specifically, leaving1.31.x–1.33.0to crash at compile time and blocking Tailwind bumps past4.1.12.The fix
StyleSheetfrom the first pass (src/compiler/compiler.ts,src/compiler/inline-variables.ts):StyleSheetExitreturningsheetwith a read-onlyStyleSheetenter visitor that registers@propertyrules and builds aVariableInliningPlan, returningundefined.Declaration: returnundefinedfor untouched declarations (so rules like.borderand.rounded-fullnever cross back into Rust's deserializer), return[]to remove unread single-definition custom properties, and return only declarations where avar()actually folded.Rule(style,nested-declarations,keyframes) to preserve exact block-scoped inlining semantics.src/compiler/inline-variables.ts,src/compiler/individual-transforms.ts):nullOptionfields (from/fallbackonvar()andenv()) for#1065/#1081.length/angle/time/resolutiontokens as rawtoken.dimensiontokens for#1188(both in folded declarations and inunparseIndividualTransform).Verification
yarn test src/onlightningcss@1.30.1: 114/114 suites, 2,362/2,362 tests passed.yarn test src/onlightningcss@1.33.0: 114/114 suites, 2,362/2,362 tests passed (includingcalc(infinity * 1px)incalc.test.tsxandabsolute-units.test.tsx).lightningcss@1.30.2: 14/14 suites, 228/228 tests passed.node --test node/__tests__/*.mjs: 42/42 passed.src/__tests__/compiler/visitor-returns.test.tsassertingStyleSheet/StyleSheetExitnever return a sheet, untouched declarations return nothing, returned declarations contain nonullfields or unsafef32integer nodes, and same-block@keyframesvariable scoping holds.mainacross medium (17.4 KB) and large (895.8 KB) Tailwind v4 sheets (default,inlineVariables: false,inlineRem: false).bench):src/native/is untouched andbench/hermes/build.mjsemits bit-for-bit identical JS bundles for bothplainandtailwindstylesheets (0% runtime change on Hermes and V8).lightningcss@1.30.1): 1.09×–1.16× faster with default inlining (895.8 KB Tailwind:1617 ms → 1484 ms) and 1.24×–1.33× faster withinlineVariables: false(1597 ms → 1290 ms), as a byproduct of skipping full-AST deserialization.Follow-ups (not in this PR)
lightningcssAST changes in1.31+(nullableContainerRule.conditionfor name-only@container) and1.32+(rotate: noneserialized as"none", affecting Tailwind'srotate-none) are tracked on a separate branch (fix/lightningcss-1.31-1.32-ast).