parcel-bundler/lightningcss `lightningcss`
Version: 1.32.0 (Mar 2026)
Deps: detect-libc@^2.0.3
Tags: latest: 1.32.0 (Mar 2026)
References: package.json — exports, entry points • README — setup, basic usage • Docs — API reference, guides • GitHub Issues — bugs, workarounds, edge cases • GitHub Discussions — Q&A, patterns, recipes • Releases — changelog, breaking changes, new APIs
Search
Use skilld search instead of grepping .skilld/ directories — hybrid semantic + keyword search across all indexed docs, issues, and releases. If skilld is unavailable, use npx -y skilld search.
skilld search "query" -p lightningcss
skilld search "issues:error handling" -p lightningcss
skilld search "releases:deprecated" -p lightningcss
Filters: docs:, issues:, releases: prefix narrows by source type.
<!-- skilld:api-changes -->
API Changes
This section documents version-specific API changes in lightningcss v1.x — prioritize recent major/minor releases.
Breaking/Significant Changes
- BREAKING: Relative color parsing changed in v1.30 — colors now require numbers instead of percentages in relative color calculations (e.g.,
rgb(from red 100% 0 0)becomesrgb(from red 100 0 0)). Code using percentages in relative color values will silently produce wrong results. source
New APIs
- NEW:
VisitorFunction<C>— v1.32 allows visitors to be functions that receiveVisitorOptionsparameter, enabling access toaddDependency()for tracking file watchers and cache invalidation source
- NEW: Resolver
resolve()method return value — v1.32 allows custom resolvers to return{external: string}to mark imports as external, preventing bundling while keeping@importin output source
- NEW:
mix-blend-modeproperty — v1.32 adds full support for themix-blend-modeproperty with all blend mode values source
- NEW:
@view-transitionrule — v1.29 implements view transitions level 2, including the rule,view-transition-class, andview-transition-groupproperties for scoped animations without additional CSS source
- NEW:
@font-feature-valuesrule — v1.29 adds parsing support for@font-feature-valuesat-rule, enabling@supports font-feature-values()checks source
- NEW:
light-dark()feature flag — v1.29 addsFeatures.LightDarkflag to explicitly control transpilation of thelight-dark()function for backwards compatibility. Flag enables control viainclude/excludeoptions source
- NEW:
:state()pseudo-class — v1.31 adds support for:state()pseudo-class for custom element state matching source
- NEW: Scroll-state container queries — v1.31 implements scroll-state container queries allowing style rules based on scroll position source
- NEW:
::picker,::picker-icon,::checkmarkpseudo-elements — v1.30 adds support for these form control pseudo-elements source
- NEW:
@propertynesting support — v1.31 allows@propertyto be nested inside at-rules like@mediasource
- NEW:
print-color-adjustproperty — v1.31 adds support for theprint-color-adjustproperty to control color/background printing behavior source
- NEW:
<string>type in@propertysyntax — v1.31 allows<string>values in@propertysyntax definitions source
- NEW:
[content-hash]CSS modules pattern — v1.27 adds content-based hashing option for CSS module pattern, supporting multiple library versions without hash conflicts source
- NEW:
puremode lints for CSS Modules — v1.27 adds pure mode option to enforce at least one class/id selector in each rule source
CSS Syntax & Lowering
- NEW: Selector nesting with pseudo-elements — v1.30 enables nesting style rules that end with pseudo-elements (e.g.,
::before,::after) source
- NEW: Interleaved declarations and nested rules — v1.30 allows mixing declarations and nested rules in the same style block (not just declarations then nested rules) source
- NEW: Reduction of
min(),max(),clamp()with number arguments — v1.31 optimizes these functions when all arguments are numbers by computing at build-time source
- NEW: Name-only
@containerqueries — v1.31 supports@container namesyntax without container-type requirement source
Deprecated APIs
- DEPRECATED:
@valueat-rule — v1.28 emits error for deprecated CSS Modules@valueat-rule (CSS spec uses@propertyinstead) source
Also changed: Granular CSS modules options (v1.25 — grid, animation, customIdents scoping flags) · animation-timeline property (v1.25) · animation-range properties (v1.26) · CSS module [content-hash] pattern (v1.27) · @container name hashing in CSS modules option (v1.28) · CustomAtRule.loc TypeScript type fix (v1.29) · skip unnecessary @supports rules when nested (v1.30) · color-scheme keyword serialization fixes (v1.32) · transform property serialization fixes (v1.32) · scale property percentage handling (v1.32)
<!-- /skilld:api-changes -->
<!-- skilld:best-practices -->
Best Practices
- Reuse the
targetsobject across all files in a build process — computing targets is expensive, and reusing the same object eliminates redundant browser compatibility lookups source
- Use specific visitor property names in object form instead of a general function — this minimizes JavaScript calls by only invoking visitors for properties you care about, dramatically improving performance source
- Return
rawCSS strings from visitors to avoid constructing full AST objects — Lightning CSS parses the string for you, making it simpler to return complex values from custom transforms source
- Compose multiple visitor plugins using
composeVisitors()instead of manually merging visitor objects — this enables publishing reusable visitor plugins and keeps logic separate while executing in a single AST pass source
- Use custom resolvers with
bundleAsync()and return{external: string}to mark imports as external, preserving specific@importrules in the bundle instead of inlining them source
- Pass a function to the
visitoroption to emit file or glob dependencies — this enables bundlers and watchers to invalidate caches when dependencies change, essential for correct rebuild behavior source
- Convert browserslist queries to Lightning CSS targets once per build using
browserslistToTargets()— this ensures consistent browser target configuration across your pipeline and automatically tracks market share changes source
- Enable
errorRecoverywhen processing third-party CSS with known invalid syntax — this gracefully omits invalid rules/declarations and returns warnings instead of failing the entire build source
- Return an empty array
[]from aRulevisitor to completely remove at-rules (e.g.@media print) and their entire contents — this is the correct pattern for filtering conditional rules source
- Use
readFileSyncinstead ofreadFilein custom resolvers when possible — synchronous reads avoid the performance overhead of async file I/O, especially important when bundling many files source
- Be as specific as possible about visitor types (e.g. prefer
Lengthover genericTokenvisitors) — narrowing the scope of what you visit reduces the frequency of JavaScript callbacks into the expensive JS/Rust boundary source
<!-- /skilld:best-practices -->