| 629 | // Register custom variants in order |
| 630 | for (let variant of topologicalSort(customVariantDependencies, { |
| 631 | onCircularDependency(path, start) { |
| 632 | let output = toCss( |
| 633 | path.map((name, idx) => { |
| 634 | return atRule('@custom-variant', name, [atRule('@variant', path[idx + 1] ?? start, [])]) |
| 635 | }), |
| 636 | ) |
| 637 | .replaceAll(';', ' { … }') |
| 638 | .replace(`@custom-variant ${start} {`, `@custom-variant ${start} { /* ← */`) |
| 639 | |
| 640 | throw new Error(`Circular dependency detected in custom variants:\n\n${output}`) |
| 641 | }, |
| 642 | })) { |
| 643 | customVariants.get(variant)?.(designSystem) |
| 644 | } |