Skip to content

Commit 2e4430f

Browse files
Remove feature flag
1 parent 2e12f39 commit 2e4430f

File tree

2 files changed

+43
-48
lines changed

2 files changed

+43
-48
lines changed

packages/tailwindcss/src/ast.ts

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { parseAtRule } from './css-parser'
22
import type { DesignSystem } from './design-system'
3-
import { enableRemoveUnusedThemeVariables } from './feature-flags'
43
import { Theme, ThemeOptions } from './theme'
54
import { DefaultMap } from './utils/default-map'
65
import { extractUsedVariables } from './utils/variables'
@@ -435,62 +434,60 @@ export function optimizeAst(
435434
for (let node of ast) {
436435
transform(node, newAst, {}, 0)
437436
}
438-
// Remove unused theme variables
439-
if (enableRemoveUnusedThemeVariables) {
440-
// Remove unused theme variables
441-
next: for (let [parent, declarations] of cssThemeVariables) {
442-
for (let declaration of declarations) {
443-
// Find out if a variable is either used directly or if any of the
444-
// variables referencing it is used.
445-
let variableUsed = isVariableUsed(
446-
declaration.property,
447-
designSystem.theme,
448-
variableDependencies,
449-
)
450-
if (variableUsed) {
451-
if (declaration.property.startsWith('--animate-')) {
452-
let parts = declaration.value!.split(/\s+/)
453-
for (let part of parts) usedKeyframeNames.add(part)
454-
}
455437

456-
continue
438+
// Remove unused theme variables
439+
next: for (let [parent, declarations] of cssThemeVariables) {
440+
for (let declaration of declarations) {
441+
// Find out if a variable is either used directly or if any of the
442+
// variables referencing it is used.
443+
let variableUsed = isVariableUsed(
444+
declaration.property,
445+
designSystem.theme,
446+
variableDependencies,
447+
)
448+
if (variableUsed) {
449+
if (declaration.property.startsWith('--animate-')) {
450+
let parts = declaration.value!.split(/\s+/)
451+
for (let part of parts) usedKeyframeNames.add(part)
457452
}
458453

459-
// Remove the declaration (from its parent)
460-
let idx = parent.indexOf(declaration)
461-
parent.splice(idx, 1)
454+
continue
455+
}
462456

463-
// If the parent is now empty, remove it and any `@layer` rules above it
464-
// from the AST
465-
if (parent.length === 0) {
466-
let path = findNode(newAst, (node) => node.kind === 'rule' && node.nodes === parent)
457+
// Remove the declaration (from its parent)
458+
let idx = parent.indexOf(declaration)
459+
parent.splice(idx, 1)
467460

468-
if (!path || path.length === 0) continue next
461+
// If the parent is now empty, remove it and any `@layer` rules above it
462+
// from the AST
463+
if (parent.length === 0) {
464+
let path = findNode(newAst, (node) => node.kind === 'rule' && node.nodes === parent)
469465

470-
// Add the root of the AST so we can delete from the top-level
471-
path.unshift({
472-
kind: 'at-root',
473-
nodes: newAst,
474-
})
466+
if (!path || path.length === 0) continue next
475467

476-
// Remove nodes from the parent as long as the parent is empty
477-
// otherwise and consist of only @layer rules
478-
do {
479-
let nodeToRemove = path.pop()
480-
if (!nodeToRemove) break
468+
// Add the root of the AST so we can delete from the top-level
469+
path.unshift({
470+
kind: 'at-root',
471+
nodes: newAst,
472+
})
481473

482-
let removeFrom = path[path.length - 1]
483-
if (!removeFrom) break
484-
if (removeFrom.kind !== 'at-root' && removeFrom.kind !== 'at-rule') break
474+
// Remove nodes from the parent as long as the parent is empty
475+
// otherwise and consist of only @layer rules
476+
do {
477+
let nodeToRemove = path.pop()
478+
if (!nodeToRemove) break
485479

486-
let idx = removeFrom.nodes.indexOf(nodeToRemove)
487-
if (idx === -1) break
480+
let removeFrom = path[path.length - 1]
481+
if (!removeFrom) break
482+
if (removeFrom.kind !== 'at-root' && removeFrom.kind !== 'at-rule') break
488483

489-
removeFrom.nodes.splice(idx, 1)
490-
} while (true)
484+
let idx = removeFrom.nodes.indexOf(nodeToRemove)
485+
if (idx === -1) break
491486

492-
continue next
493-
}
487+
removeFrom.nodes.splice(idx, 1)
488+
} while (true)
489+
490+
continue next
494491
}
495492
}
496493

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
export const enableRemoveUnusedThemeVariables = process.env.FEATURES_ENV !== 'stable'
2-
31
export const enableUserValid = process.env.FEATURES_ENV !== 'stable'

0 commit comments

Comments
 (0)