diff --git a/src/compiler/atRules.ts b/src/compiler/atRules.ts index deac60d4..bc8cb173 100644 --- a/src/compiler/atRules.ts +++ b/src/compiler/atRules.ts @@ -37,37 +37,13 @@ export interface ReactNativeAtRule { export function maybeMutateReactNativeOptions( rule: Rule | ReactNativeAtRule, - builder: StylesheetBuilder, + _builder: StylesheetBuilder, ) { if (rule.type !== "custom" || rule.value?.name !== "react-native") { return; } - const { declarations } = rule.value.body.value; - if (!declarations) return; - - for (const declaration of declarations) { - if (declaration.property !== "custom") continue; - - switch (declaration.value.name) { - case "preserve-variables": { - declaration.value.value.forEach((token) => { - if (token.type !== "dashed-ident") { - return; - } - - if (token.value !== "true" && token.value !== "false") { - return; - } - - builder.setOptions("preserveVariables", token.value === "true"); - }); - break; - } - default: - break; - } - } + // TODO: Add inline options } /*********************************************** diff --git a/src/compiler/compiler.ts b/src/compiler/compiler.ts index b3561822..00b4f10d 100644 --- a/src/compiler/compiler.ts +++ b/src/compiler/compiler.ts @@ -9,7 +9,6 @@ import { type CustomAtRules, type MediaRule, type Rule, - type TokenOrValue, type Visitor, } from "lightningcss"; @@ -89,7 +88,8 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) { } else { logger( `firstPass buffer too large to log in full (${firstPass.length} bytes). Preview: ` + - firstPass.subarray(0, 1024).toString() + "..." + firstPass.subarray(0, 1024).toString() + + "...", ); } } @@ -126,27 +126,6 @@ export function compile(code: Buffer | string, options: CompilerOptions = {}) { }, }; - if (options.stripUnusedVariables) { - const onVarUsage = (token: TokenOrValue) => { - if (token.type === "function") { - token.value.arguments.forEach((token) => onVarUsage(token)); - } else if (token.type === "var") { - builder.varUsage.add(token.value.name.ident); - if (token.value.fallback) { - const fallbackValues = token.value.fallback; - fallbackValues.forEach((varObj) => onVarUsage(varObj)); - } - } - }; - - visitor.Declaration = (decl) => { - if (decl.property === "unparsed" || decl.property === "custom") { - decl.value.value.forEach((token) => onVarUsage(token)); - } - return decl; - }; - } - lightningcss({ code: firstPass, visitor, diff --git a/src/compiler/compiler.types.ts b/src/compiler/compiler.types.ts index c34bc650..9f71729d 100644 --- a/src/compiler/compiler.types.ts +++ b/src/compiler/compiler.types.ts @@ -12,11 +12,6 @@ export interface CompilerOptions { stylesheetOrder?: number; features?: FeatureFlagRecord; logger?: (message: string) => void | Debugger; - /** Strip unused variables declarations. Defaults: false */ - stripUnusedVariables?: boolean; - /** @internal */ - ignorePropertyWarningRegex?: (string | RegExp)[]; - preserveVariables?: boolean; hexColors?: boolean; colorPrecision?: number; } diff --git a/src/compiler/stylesheet.ts b/src/compiler/stylesheet.ts index e7c8489e..a23514a8 100644 --- a/src/compiler/stylesheet.ts +++ b/src/compiler/stylesheet.ts @@ -331,15 +331,6 @@ export class StylesheetBuilder { forceTuple, ); } else if (property.startsWith("--")) { - // If we have enabled variable usage tracking, skip unused variables - if ( - this.options.stripUnusedVariables && - !property.startsWith("--__rn-css") && - !this.varUsage.has(property) - ) { - return; - } - rule.v ??= []; rule.v.push([property.slice(2), value]); } else if (isStyleFunction(value)) {