Repository navigation
v4.0.0
Major Changes
-
#210
4f75d34Thanks @castastrophe! - Built for design-token stylesheets: dependency-aware sorting for CSS custom properties — including nested var() fallback chains — with TypeScript types and Node 18+ / PostCSS 8 support.Breaking changes
- Full ESM migration.
"type": "module"is set inpackage.json,module.exportshas been replaced withexport default, andexportsconditions are declared. CJS consumers doingconst plugin = require("postcss-custom-prop-sorting")must switch toimport plugin from "postcss-custom-prop-sorting"(or dynamicawait import(...)from a CJS file). - Dropped PostCSS 7 peer support.
peerDependencies.postcssis now^8.4.0. PostCSS 7 has been EOL since 2022; PostCSS 8 migration guide. - Widened supported Node range.
engines.nodeis now>=18(down from>=24). This is a compatibility widening for consumers, but if you were relying on Node 24-only syntax in a downstream extension, be aware the plugin now runs on Node 18 too.
Fixed
- Custom-property dependency reordering was inverted. Previously, a property whose value referenced another (
--a: var(--e)) was left ahead of its dependency instead of being moved after it. Fixed and validated by real byte-for-byte fixture assertions (previously the tests counted warnings). - Multi-dependency support. A dependent with more than one in-rule dependency (
--c: var(--x, var(--y))) now correctly follows all of its dependencies. The prior single-pass "splice + queue" approach silently lost the second constraint. - Circular dependencies no longer hit a 100-iteration
console.logfallback. Cycles are now detected explicitly and emit a proper PostCSS warning; the remaining dependents are appended in sort order rather than looping. var()regex modernized. Now handles whitespace (var( --foo )) and nested fallback dependencies (var(--x, var(--y))records deps on both--xand--y).- Warnings now route through the correct API.
decl.warn(rule, ...)(a silent no-op — first arg should be the PostCSSResult) is nowdecl.warn(result, ...). The 100-iterationconsole.logis nowrule.warn(result, ...). raws.after/raws.beforehardened againstundefined. Rules containing only custom properties no longer risk producing"undefined\n"in output or crashing ondecl.next().- JSDoc typedef corrected.
sortOrderreturnsnumber, notPropSet[].
Added
- TypeScript declarations. A hand-written
index.d.tsexportsPropSetandOptions. Types are wired intopackage.jsonviatypesand insideexportsconditions. - Comprehensive fixture coverage. 8 new fixture/expected pairs covering nested
@mediarules,:root, deep dependency chains, duplicates, plain rules with no custom properties,var()whitespace, nested fallback dependencies, rules containing only custom properties, and circular dependencies. Test count went from 4 → 12; coverage from 89.1% → 100% statements / 100% functions.
Changed
- Release pipeline swapped from
semantic-releasetochangesets. Releases are now driven by human-authored.changeset/*.mdfiles aggregated into a "Version Packages" PR. GitHub Actions publishes to npm with provenance (OIDC) when that PR merges. See.changeset/README.mdfor the contributor workflow. - Commitlint / conventional-commit enforcement removed. With changesets carrying the release-note authorship, commit messages are no longer parsed to derive versions; the pre-commit hook now runs
lint-stagedinstead of the full test suite. - CI test matrix reworked. Full Ava suite runs on Node 22 & 24 (Ava 8's floor). A lightweight smoke job installs only
postcssand runs the plugin end-to-end on Node 18 & 20 to prove the widenedengines.nodeclaim. A Prettier check job gates formatting. - README rewritten. The API example now shows real PostCSS 8 syntax (
postcss([plugin]).process(...)instead of the fictitiouspostcss.process([plugin])), the Contributing link points at the correct repo, and a new "Dependency handling" section documents the topological reorder semantics and cycle-warning behavior.
- Full ESM migration.