fix(compiler-sfc): avoid deindent when lang is jsx/tsx

fix #12755
This commit is contained in:
Evan You 2022-08-23 09:18:36 +08:00
parent 810f6d12ed
commit 46ca7bcddc

View File

@ -179,11 +179,11 @@ export function parseComponent(
let text = source.slice(currentBlock.start, currentBlock.end) let text = source.slice(currentBlock.start, currentBlock.end)
if ( if (
options.deindent === true || 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 && (options.deindent !== false &&
!( !(
currentBlock.type === 'script' && currentBlock.type === 'script' &&
(!currentBlock.lang || currentBlock.lang === 'ts') (!currentBlock.lang || /^(j|t)sx?$/.test(currentBlock.lang))
)) ))
) { ) {
text = deindent(text) text = deindent(text)