From c77611f57c63ea1bde03c618677234def26b48c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Wed, 26 Mar 2025 15:51:14 +0100 Subject: [PATCH] async write the cache --- packages/babel-compiler/babel-compiler.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/babel-compiler/babel-compiler.js b/packages/babel-compiler/babel-compiler.js index 09d680c19e..8181009167 100644 --- a/packages/babel-compiler/babel-compiler.js +++ b/packages/babel-compiler/babel-compiler.js @@ -209,8 +209,12 @@ BCp.processOneFileForTarget = function (inputFile, source) { if (self.cacheDirectory) { const cacheFilePath = path.join(self.cacheDirectory, cacheContext, cacheKey + '.json'); try { - fs.mkdirSync(path.dirname(cacheFilePath), { recursive: true }); - fs.writeFileSync(cacheFilePath, JSON.stringify(compilation), 'utf8'); + const writeFileCache = async () => { + await fs.promises.mkdir(path.dirname(cacheFilePath), { recursive: true }); + await fs.promises.writeFile(cacheFilePath, JSON.stringify(compilation), 'utf8'); + }; + // Asynchronously write the cache without blocking + writeFileCache(); } catch (e) { // If file caching fails, ignore the error. }