From c9a423848bf36b2d0caa0713cc94bbcb3f355122 Mon Sep 17 00:00:00 2001 From: sweetliquid Date: Mon, 21 Mar 2022 05:14:02 +0800 Subject: [PATCH] fix(transformers): errors.map is not a function (#7672) --- .../transformers/html/src/HTMLTransformer.js | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/transformers/html/src/HTMLTransformer.js b/packages/transformers/html/src/HTMLTransformer.js index 21b12eb8ab5..2f13a963559 100644 --- a/packages/transformers/html/src/HTMLTransformer.js +++ b/packages/transformers/html/src/HTMLTransformer.js @@ -41,19 +41,22 @@ export default (new Transformer({ try { hasScripts = collectDependencies(asset, ast); } catch (errors) { - throw new ThrowableDiagnostic({ - diagnostic: errors.map(error => ({ - message: error.message, - origin: '@parcel/transformer-html', - codeFrames: [ - { - filePath: error.filePath, - language: 'html', - codeHighlights: [error.loc], - }, - ], - })), - }); + if (Array.isArray(errors)) { + throw new ThrowableDiagnostic({ + diagnostic: errors.map(error => ({ + message: error.message, + origin: '@parcel/transformer-html', + codeFrames: [ + { + filePath: error.filePath, + language: 'html', + codeHighlights: [error.loc], + }, + ], + })), + }); + } + throw errors; } const {assets: inlineAssets, hasScripts: hasInlineScripts} =