From 6482276f05d39eaffba717df322ff48d497156f2 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 13 Mar 2026 14:40:30 +0100 Subject: [PATCH 1/2] perf(transform): skip eval cache for __mkPreval entry-point evaluations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __mkPreval is the unique entry-point evaluation per source file — each call has unique sourceCode + expressionCode, so the eval cache never hits. Add useEvalCache parameter to Module.evaluate() and pass false from vmEvaluator. Co-Authored-By: Claude Opus 4.6 --- packages/transform/src/evaluation/module.mts | 8 +++++--- packages/transform/src/evaluation/vmEvaluator.mts | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/transform/src/evaluation/module.mts b/packages/transform/src/evaluation/module.mts index 830567c77..d9822172d 100644 --- a/packages/transform/src/evaluation/module.mts +++ b/packages/transform/src/evaluation/module.mts @@ -168,7 +168,7 @@ export class Module { }, ); - evaluate(text: string, only: string[] | null = null): void { + evaluate(text: string, only: string[] | null = null, useEvalCache = true): void { const { filename } = this; // Find last matching rule (iterate backwards, break on first match) let action: EvalRule['action'] = 'ignore'; @@ -184,7 +184,7 @@ export class Module { const cacheKey = [this.filename, ...(only ?? [])]; - if (EvalCache.has(cacheKey, text)) { + if (useEvalCache && EvalCache.has(cacheKey, text)) { this.exports = EvalCache.get(cacheKey, text); return; } @@ -234,7 +234,9 @@ export class Module { }), ); - EvalCache.set(cacheKey, text, this.exports); + if (useEvalCache) { + EvalCache.set(cacheKey, text, this.exports); + } } static invalidate = (): void => { diff --git a/packages/transform/src/evaluation/vmEvaluator.mts b/packages/transform/src/evaluation/vmEvaluator.mts index 30c0a48fa..0b3957898 100644 --- a/packages/transform/src/evaluation/vmEvaluator.mts +++ b/packages/transform/src/evaluation/vmEvaluator.mts @@ -28,7 +28,9 @@ export const __mkPreval = (() => { try { const mod = new Module(filename, evaluationRules, resolveFilename); - mod.evaluate(codeForEvaluation, ['__mkPreval']); + // useEvalCache=false: each source file produces unique codeForEvaluation (different sourceCode + + // expressionCode), so the eval cache would never hit — skip the unnecessary hashing and map storage. + mod.evaluate(codeForEvaluation, ['__mkPreval'], /* useEvalCache */ false); const result = (mod.exports as { __mkPreval: unknown }).__mkPreval; From 9036b5fd8a997ad578f3261619dd30875c328270 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Fri, 13 Mar 2026 14:43:00 +0100 Subject: [PATCH 2/2] chore: add change file for eval cache skip Co-Authored-By: Claude Opus 4.6 --- ...fel-transform-d54d4756-3495-4c37-bf22-5076d3c8fd83.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@griffel-transform-d54d4756-3495-4c37-bf22-5076d3c8fd83.json diff --git a/change/@griffel-transform-d54d4756-3495-4c37-bf22-5076d3c8fd83.json b/change/@griffel-transform-d54d4756-3495-4c37-bf22-5076d3c8fd83.json new file mode 100644 index 000000000..e0ae703aa --- /dev/null +++ b/change/@griffel-transform-d54d4756-3495-4c37-bf22-5076d3c8fd83.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "perf: skip eval cache for __mkPreval entry-point evaluations", + "packageName": "@griffel/transform", + "email": "olfedias@microsoft.com", + "dependentChangeType": "patch" +}