Skip to content

Commit 8740cbe

Browse files
committed
Handle future and experimental config keys during upgrade
1 parent 7c0eeaa commit 8740cbe

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

packages/@tailwindcss-upgrade/src/codemods/config/migrate-js-config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ function canMigrateConfig(unresolvedConfig: Config, source: string): boolean {
411411
'presets',
412412
'prefix', // Prefix is handled in the dedicated prefix migrator
413413
'corePlugins',
414+
'future',
415+
'experimental',
414416
]
415417

416418
if (Object.keys(unresolvedConfig).some((key) => !knownProperties.includes(key))) {
@@ -425,6 +427,29 @@ function canMigrateConfig(unresolvedConfig: Config, source: string): boolean {
425427
return false
426428
}
427429

430+
// If there are unknown "future" flags we should bail
431+
if (unresolvedConfig.future && unresolvedConfig.future !== 'all') {
432+
let knownFutureFlags = [
433+
'hoverOnlyWhenSupported',
434+
'respectDefaultRingColorOpacity',
435+
'disableColorOpacityUtilitiesByDefault',
436+
'relativeContentPathsByDefault',
437+
]
438+
439+
if (Object.keys(unresolvedConfig.future).some((key) => !knownFutureFlags.includes(key))) {
440+
return false
441+
}
442+
}
443+
444+
// If there are unknown "experimental" flags we should bail
445+
if (unresolvedConfig.experimental && unresolvedConfig.experimental !== 'all') {
446+
let knownFutureFlags = ['generalizedModifiers']
447+
448+
if (Object.keys(unresolvedConfig.experimental).some((key) => !knownFutureFlags.includes(key))) {
449+
return false
450+
}
451+
}
452+
428453
// Only migrate the config file if all top-level theme keys are allowed to be
429454
// migrated
430455
if (theme && typeof theme === 'object') {

packages/tailwindcss/src/compat/config/resolve-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface ResolutionContext {
3333
let minimal: ResolvedConfig = {
3434
blocklist: [],
3535
future: {},
36+
experimental: {},
3637
prefix: '',
3738
important: false,
3839
darkMode: null,

packages/tailwindcss/src/compat/config/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,12 @@ export interface UserConfig {
105105
export interface ResolvedConfig {
106106
future: Record<string, boolean>
107107
}
108+
109+
// `experimental` key support
110+
export interface UserConfig {
111+
experimental?: 'all' | Record<string, boolean>
112+
}
113+
114+
export interface ResolvedConfig {
115+
experimental: Record<string, boolean>
116+
}

0 commit comments

Comments
 (0)