From c88116a49fd423ebf0823b4a4aca84a55cad4308 Mon Sep 17 00:00:00 2001 From: Sergey G Date: Mon, 13 Nov 2023 12:01:13 +0100 Subject: [PATCH] Simplify invalidateOnFileChange() in Transformers (#9379) Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> --- .../posthtml/src/PostHTMLTransformer.js | 13 +++++-------- packages/transformers/pug/src/PugTransformer.js | 2 +- .../transformers/stylus/src/StylusTransformer.js | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/transformers/posthtml/src/PostHTMLTransformer.js b/packages/transformers/posthtml/src/PostHTMLTransformer.js index e3f5283a1fd..549f7fcdabb 100644 --- a/packages/transformers/posthtml/src/PostHTMLTransformer.js +++ b/packages/transformers/posthtml/src/PostHTMLTransformer.js @@ -105,14 +105,11 @@ export default (new Transformer({ }); if (res.messages) { - await Promise.all( - res.messages.map(({type, file: filePath}) => { - if (type === 'dependency') { - return asset.invalidateOnFileChange(filePath); - } - return Promise.resolve(); - }), - ); + for (let {type, file: filePath} of res.messages) { + if (type === 'dependency') { + asset.invalidateOnFileChange(filePath); + } + } } asset.setAST({ diff --git a/packages/transformers/pug/src/PugTransformer.js b/packages/transformers/pug/src/PugTransformer.js index 34149ee7ae7..a65ebb3dfd5 100644 --- a/packages/transformers/pug/src/PugTransformer.js +++ b/packages/transformers/pug/src/PugTransformer.js @@ -31,7 +31,7 @@ export default (new Transformer({ }); for (let filePath of render.dependencies) { - await asset.invalidateOnFileChange(filePath); + asset.invalidateOnFileChange(filePath); } asset.type = 'html'; diff --git a/packages/transformers/stylus/src/StylusTransformer.js b/packages/transformers/stylus/src/StylusTransformer.js index 5e6a9d93bef..38a38afa8ba 100644 --- a/packages/transformers/stylus/src/StylusTransformer.js +++ b/packages/transformers/stylus/src/StylusTransformer.js @@ -198,7 +198,7 @@ async function getDependencies( // Recursively process resolved files as well to get nested deps for (let resolved of found) { if (!seen.has(resolved)) { - await asset.invalidateOnFileChange(resolved); + asset.invalidateOnFileChange(resolved); let code = await asset.fs.readFile(resolved, 'utf8'); for (let [path, resolvedPath] of await getDependencies(