Skip to content

Commit af9843b

Browse files
committed
use signature options in upgrade tool
1 parent b059d94 commit af9843b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/@tailwindcss-upgrade/src/codemods/template/migrate-arbitrary-variants.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { cloneCandidate } from '../../../../tailwindcss/src/candidate'
2+
import { createSignatureOptions } from '../../../../tailwindcss/src/canonicalize-candidates'
23
import type { Config } from '../../../../tailwindcss/src/compat/plugin-api'
34
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
45
import {
@@ -14,8 +15,9 @@ export function migrateArbitraryVariants(
1415
_userConfig: Config | null,
1516
rawCandidate: string,
1617
): string {
17-
let signatures = computeVariantSignature.get(designSystem)
18-
let variants = preComputedVariants.get(designSystem)
18+
let signatureOptions = createSignatureOptions(designSystem)
19+
let signatures = computeVariantSignature.get(signatureOptions)
20+
let variants = preComputedVariants.get(signatureOptions)
1921

2022
for (let readonlyCandidate of designSystem.parseCandidate(rawCandidate)) {
2123
// We are only interested in the variants

packages/@tailwindcss-upgrade/src/codemods/template/migrate.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'node:fs/promises'
22
import path, { extname } from 'node:path'
3+
import { createSignatureOptions } from '../../../../tailwindcss/src/canonicalize-candidates'
34
import type { Config } from '../../../../tailwindcss/src/compat/plugin-api'
45
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
56
import { computeUtilitySignature } from '../../../../tailwindcss/src/signatures'
@@ -39,11 +40,10 @@ export const DEFAULT_MIGRATIONS: Migration[] = [
3940
migrateModernizeArbitraryValues,
4041
]
4142

42-
let migrateCached = new DefaultMap<
43-
DesignSystem,
44-
DefaultMap<Config | null, DefaultMap<string, Promise<string>>>
45-
>((designSystem) => {
46-
return new DefaultMap((userConfig) => {
43+
let migrateCached = new DefaultMap((designSystem: DesignSystem) => {
44+
let options = createSignatureOptions(designSystem)
45+
46+
return new DefaultMap((userConfig: Config | null) => {
4747
return new DefaultMap(async (rawCandidate) => {
4848
let original = rawCandidate
4949

@@ -57,7 +57,7 @@ let migrateCached = new DefaultMap<
5757
// Verify that the candidate actually makes sense at all. E.g.: `duration`
5858
// is not a valid candidate, but it will parse because `duration-<number>`
5959
// exists.
60-
let signature = computeUtilitySignature.get(designSystem).get(rawCandidate)
60+
let signature = computeUtilitySignature.get(options).get(rawCandidate)
6161
if (typeof signature !== 'string') return original
6262

6363
return rawCandidate

0 commit comments

Comments
 (0)