Skip to content

Commit

Permalink
fix: caching of tailwindcss 3
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Jan 23, 2025
1 parent 00f4045 commit 81cef99
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/rules/tailwind-sort-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,11 @@ const defaultOptions = {
variables: DEFAULT_VARIABLE_NAMES
} as const satisfies Options[0];

console.log("INIT FILE");

export const tailwindSortClasses: ESLintRule<Options> = {
name: "sort-classes" as const,
rule: {
create(ctx) {

console.log("CREATE SORT CLASSES");

const { attributes, callees, tags, variables } = getOptions(ctx);

const lintLiterals = (ctx: Rule.RuleContext, literals: Literal[]) => {
Expand Down
1 change: 0 additions & 1 deletion src/tailwind/async/class-order.sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const getClassOrderSync = createSyncFn<(version: SupportedTailwindVersion, reque
...env.NODE_ENV === "test" && { execArgv: ["--import", TsRunner.TSX] }
});

console.log("create worker sync");

export function getClassOrder(request: GetClassOrderRequest): GetClassOrderResponse {

Expand Down
11 changes: 6 additions & 5 deletions src/tailwind/v3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ export function loadTailwindConfig(path: string | undefined) {

const CACHE = new Map<string, ReturnType<typeof setupContextUtils.createContext>>();

export function createTailwindContextFromConfigFile(path: string = "default") {
if(CACHE.has(path)){
console.log("v3 cached designSystem");
return CACHE.get(path);
export function createTailwindContextFromConfigFile(path?: string) {
const cacheKey = path ?? "default";

if(CACHE.has(cacheKey)){
return CACHE.get(cacheKey);
}

const tailwindConfig = loadTailwindConfig(path);
const context = setupContextUtils.createContext?.(tailwindConfig) ?? setupContextUtils.default?.createContext?.(tailwindConfig);

CACHE.set(path, context);
CACHE.set(cacheKey, context);

return context;
}

0 comments on commit 81cef99

Please sign in to comment.