Skip to content

Commit

Permalink
fix(plugin-vue): handle TS decorators in rewriteDefault fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 30, 2022
1 parent 7082ccf commit babf67e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,17 @@ async function genScriptCode(
(!script.lang || (script.lang === 'ts' && options.devServer)) &&
!script.src
) {
const userPlugins = options.script?.babelParserPlugins || []
const defaultPlugins =
script.lang === 'ts'
? userPlugins.includes('decorators')
? (['typescript'] as const)
: (['typescript', 'decorators-legacy'] as const)
: []
scriptCode = options.compiler.rewriteDefault(
script.content,
'_sfc_main',
script.lang === 'ts' ? ['typescript'] : undefined
[...defaultPlugins, ...userPlugins]
)
map = script.map
} else {
Expand Down

0 comments on commit babf67e

Please sign in to comment.