Skip to content

Tree-shake property defaults with per-utility @property declarations #34

@goulvenclech

Description

@goulvenclech

Composable utilities declare custom property defaults in Preset.property_defaults, collected and emitted as a universal selector block (*, ::after, ::before, …) by CompiledConfig::compile(). This block is always emitted in full, even when none of the associated utilities match scanned HTML — no tree-shaking.

Tailwind CSS v4 returns @property declarations inline from each utility handler (via atRoot()), hoists and deduplicates them. Defaults are only emitted for properties actually referenced by matched utilities.

Current state

Preset.property_defaults: Vec<CssEntry> is collected at compile time, emitted unconditionally. CssEntries returned by rules has no concept of hoisted/root declarations.

Direction

Extend CssEntries (or introduce a wrapper) so rules can return optional root-level declarations alongside regular property–value pairs. On match, root declarations are collected, deduplicated, and hoisted as @property rules (inherits: false) — replacing the universal selector approach. property_defaults is then removed from Preset.

Not in scope: full @layer ordering or @property syntax validation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions