Skip to content

Commit babf67e

Browse files
committed
fix(plugin-vue): handle TS decorators in rewriteDefault fallback
1 parent 7082ccf commit babf67e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/plugin-vue/src/main.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,17 @@ async function genScriptCode(
306306
(!script.lang || (script.lang === 'ts' && options.devServer)) &&
307307
!script.src
308308
) {
309+
const userPlugins = options.script?.babelParserPlugins || []
310+
const defaultPlugins =
311+
script.lang === 'ts'
312+
? userPlugins.includes('decorators')
313+
? (['typescript'] as const)
314+
: (['typescript', 'decorators-legacy'] as const)
315+
: []
309316
scriptCode = options.compiler.rewriteDefault(
310317
script.content,
311318
'_sfc_main',
312-
script.lang === 'ts' ? ['typescript'] : undefined
319+
[...defaultPlugins, ...userPlugins]
313320
)
314321
map = script.map
315322
} else {

0 commit comments

Comments
 (0)