From 2694260e8dbf822b4d86ac757a23faa8001dd1a5 Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 3 Oct 2024 22:40:29 +0200 Subject: [PATCH] add loadMDXWithCaching comment --- packages/docusaurus-mdx-loader/src/loader.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/docusaurus-mdx-loader/src/loader.ts b/packages/docusaurus-mdx-loader/src/loader.ts index 78120ac9f499..9bd9880ecda8 100644 --- a/packages/docusaurus-mdx-loader/src/loader.ts +++ b/packages/docusaurus-mdx-loader/src/loader.ts @@ -150,9 +150,7 @@ async function loadMDXWithCaching({ // Note: once we introduce RSCs we'll probably have 3 compilations // Note: we can't use string keys in WeakMap // But we could eventually use WeakRef for the values - function deleteCacheEntry() { - options.crossCompilerCache?.delete(cacheKey); - } + const deleteCacheEntry = () => options.crossCompilerCache?.delete(cacheKey); const cacheEntry = options.crossCompilerCache?.get(cacheKey); @@ -187,7 +185,9 @@ async function loadMDXWithCaching({ }); } return promise; - } else if (compilerName === 'server') { + } + // Server compilation always uses the result of the client compilation above + else if (compilerName === 'server') { if (cacheEntry) { deleteCacheEntry(); return cacheEntry.promise;