From 46ca7bcddc06c50796ccff82d8c45693f1f14f47 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 23 Aug 2022 09:18:36 +0800 Subject: [PATCH] fix(compiler-sfc): avoid deindent when lang is jsx/tsx fix #12755 --- packages/compiler-sfc/src/parseComponent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/compiler-sfc/src/parseComponent.ts b/packages/compiler-sfc/src/parseComponent.ts index 65b858c9fc0..05489280e63 100644 --- a/packages/compiler-sfc/src/parseComponent.ts +++ b/packages/compiler-sfc/src/parseComponent.ts @@ -179,11 +179,11 @@ export function parseComponent( let text = source.slice(currentBlock.start, currentBlock.end) if ( options.deindent === true || - // by default, deindent unless it's script with default lang or ts + // by default, deindent unless it's script with default lang or (j/t)sx? (options.deindent !== false && !( currentBlock.type === 'script' && - (!currentBlock.lang || currentBlock.lang === 'ts') + (!currentBlock.lang || /^(j|t)sx?$/.test(currentBlock.lang)) )) ) { text = deindent(text)