Skip to content

fix: safely tokenize CSS unit conversions and preserve lifecycle context - #51

Merged
sonofmagic merged 2 commits into
mainfrom
codex/unit-tokenizer
Oct 11, 2026
Merged

sonofmagic merged 2 commits into
mainfrom
codex/unit-tokenizer

Conversation

@sonofmagic

Copy link
Copy Markdown
Member

CSS unit conversion currently uses a regex that can partially match identifiers, lose signed/scientific values, and stop protecting nested var() fallbacks. This change tokenizes complete CSS dimensions by default, preserving strings and URLs, and applies minimum values by absolute magnitude. Explicit unitRegex remains available.

The shared walker gains an optional whole-value transformer and importance-aware fallback deduplication. Programmatic ASTs receive a temporary Input context without fabricated source metadata. Legacy wrappers preserve their matching behavior and forward native PostCSS lifecycle helpers. Preset factories accept public and custom option interfaces.

Release intents: minor for postcss-plugin-shared; patch for postcss-rule-unit-converter, with dependent-package updates handled by the release plan. This PR does not publish npm packages or merge a version PR.

Validation: workspace build/lint/typecheck, 405 tests across all consumers, converter per-file 100% coverage, TSD, packed ESM/CJS and subpath checks, website build, repo doctor/check. Bilingual API and migration documentation describe first-match rules, single-pass conversion, repeated processing, and entry-level exclusions.

@sonofmagic
sonofmagic merged commit 27599bc into main Oct 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant