Skip to content

Commit

Permalink
fix(compiler-sfc): avoid deindent when lang is jsx/tsx
Browse files Browse the repository at this point in the history
fix #12755
  • Loading branch information
yyx990803 committed Aug 23, 2022
1 parent 810f6d1 commit 46ca7bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/compiler-sfc/src/parseComponent.ts
Expand Up @@ -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)
Expand Down

1 comment on commit 46ca7bc

@SnowingFox
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but actually, .js file can also write jsx

Please sign in to comment.