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>
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).