From 33cdb6cff776e1b37f22210a57880e27a3dfb5d4 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Wed, 12 Aug 2026 15:40:52 -0400 Subject: [PATCH 1/2] Simplify process-content to use async iteration --- lib/process-content.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/process-content.js b/lib/process-content.js index a048403..edcf034 100644 --- a/lib/process-content.js +++ b/lib/process-content.js @@ -43,18 +43,19 @@ module.exports = function processContent( return runPostcss(postcss, content, filename, plugins, parserList) } -function runPostcss(postcss, content, filename, plugins, parsers, index) { - if (!index) index = 0 - return postcss(plugins) - .process(content, { - from: filename, - parser: parsers[index], - }) - .catch(err => { - // If there's an error, try the next parser - index++ - // If there are no parsers left, throw it - if (index === parsers.length) throw err - return runPostcss(postcss, content, filename, plugins, parsers, index) - }) +async function runPostcss(postcss, content, filename, plugins, parsers) { + let lastError + + for (const parser of parsers) { + try { + return await postcss(plugins).process(content, { + from: filename, + parser, + }) + } catch (err) { + lastError = err + } + } + + throw lastError } From d8277baea094f4e132d6f17c33a4867713979511 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman Date: Thu, 13 Aug 2026 10:32:04 -0400 Subject: [PATCH 2/2] Reuse processor instance --- lib/process-content.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/process-content.js b/lib/process-content.js index edcf034..4ce6cc9 100644 --- a/lib/process-content.js +++ b/lib/process-content.js @@ -45,10 +45,11 @@ module.exports = function processContent( async function runPostcss(postcss, content, filename, plugins, parsers) { let lastError + const processor = postcss(plugins) for (const parser of parsers) { try { - return await postcss(plugins).process(content, { + return await processor.process(content, { from: filename, parser, })