Skip to content

Commit 02ba94f

Browse files
committed
ensure we canonicalize at the end
A bunch of migrations were moved to `canonicalizeCandidates`, so we still have to run that at the end. Also used: ```css @theme { --*: initial; } ``` To make the design system a bit faster.
1 parent 80029cd commit 02ba94f

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

packages/@tailwindcss-upgrade/src/codemods/template/migrate-modernize-arbitrary-values.test.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ import { migrateModernizeArbitraryValues } from './migrate-modernize-arbitrary-v
99
import { migratePrefix } from './migrate-prefix'
1010
vi.spyOn(versions, 'isMajor').mockReturnValue(true)
1111

12+
const css = String.raw
13+
1214
function migrate(designSystem: DesignSystem, userConfig: UserConfig | null, rawCandidate: string) {
1315
for (let migration of [
1416
migrateEmptyArbitraryValues,
1517
migratePrefix,
1618
migrateModernizeArbitraryValues,
1719
migrateArbitraryVariants,
20+
(designSystem: DesignSystem, _, rawCandidate: string) => {
21+
return designSystem.canonicalizeCandidates([rawCandidate]).pop() ?? rawCandidate
22+
},
1823
]) {
1924
rawCandidate = migration(designSystem, userConfig, rawCandidate)
2025
}
@@ -37,9 +42,15 @@ test.each([
3742
['not-group-[]:flex', 'not-in-[.group]:flex'],
3843
['not-group-[]/name:flex', 'not-in-[.group\\/name]:flex'],
3944
])('%s => %s (%#)', async (candidate, result) => {
40-
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', {
41-
base: __dirname,
42-
})
45+
let designSystem = await __unstable__loadDesignSystem(
46+
css`
47+
@import 'tailwindcss';
48+
@theme {
49+
--*: initial;
50+
}
51+
`,
52+
{ base: __dirname },
53+
)
4354

4455
expect(migrate(designSystem, {}, candidate)).toEqual(result)
4556
})
@@ -66,9 +77,15 @@ test.each([
6677
['not-group-[]:tw-flex', 'tw:not-in-[.tw\\:group]:flex'],
6778
['not-group-[]/name:tw-flex', 'tw:not-in-[.tw\\:group\\/name]:flex'],
6879
])('%s => %s (%#)', async (candidate, result) => {
69-
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss" prefix(tw);', {
70-
base: __dirname,
71-
})
80+
let designSystem = await __unstable__loadDesignSystem(
81+
css`
82+
@import 'tailwindcss' prefix(tw);
83+
@theme {
84+
--*: initial;
85+
}
86+
`,
87+
{ base: __dirname },
88+
)
7289

7390
expect(migrate(designSystem, { prefix: 'tw-' }, candidate)).toEqual(result)
7491
})

0 commit comments

Comments
 (0)