@@ -3,6 +3,7 @@ import path from 'node:path'
33import url from 'node:url'
44import type { Config } from 'tailwindcss'
55import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
6+ import { DefaultMap } from '../../../../tailwindcss/src/utils/default-map'
67import { printCandidate } from '../candidates'
78
89const __filename = url . fileURLToPath ( import . meta. url )
@@ -46,24 +47,26 @@ const THEME_KEYS = {
4647 'blur-xs' : '--blur-xs' ,
4748}
4849
50+ const DESIGN_SYSTEMS = new DefaultMap ( ( base ) => {
51+ return __unstable__loadDesignSystem ( '@import "tailwindcss";' , { base } )
52+ } )
4953const SEEDED = new WeakSet < DesignSystem > ( )
5054
5155export async function legacyClasses (
5256 designSystem : DesignSystem ,
5357 _userConfig : Config ,
5458 rawCandidate : string ,
5559) : Promise < string > {
56- // Prepare design system with the unknown legacy classes
60+ // Ensure the "old" classes exist as static utilities to make the migration
61+ // easier because the "root" will point to the full class.
5762 if ( ! SEEDED . has ( designSystem ) ) {
5863 for ( let old in LEGACY_CLASS_MAP ) {
5964 designSystem . utilities . static ( old , ( ) => [ ] )
6065 }
6166 SEEDED . add ( designSystem )
6267 }
6368
64- let defaultDesignSystem = await __unstable__loadDesignSystem ( '@import "tailwindcss";' , {
65- base : __dirname ,
66- } )
69+ let defaultDesignSystem = await DESIGN_SYSTEMS . get ( __dirname )
6770
6871 for ( let candidate of designSystem . parseCandidate ( rawCandidate ) ) {
6972 if ( candidate . kind === 'static' && Object . hasOwn ( LEGACY_CLASS_MAP , candidate . root ) ) {
0 commit comments