@@ -31,15 +31,15 @@ export async function transformMain(
31
31
const { descriptor, errors } = createDescriptor ( filename , code , options )
32
32
33
33
if ( errors . length ) {
34
- errors . forEach ( ( error ) =>
34
+ errors . forEach ( error =>
35
35
pluginContext . error ( createRollupError ( filename , error ) )
36
36
)
37
37
return null
38
38
}
39
39
40
40
// feature information
41
- const hasScoped = descriptor . styles . some ( ( s ) => s . scoped )
42
- const hasCssModules = descriptor . styles . some ( ( s ) => s . module )
41
+ const hasScoped = descriptor . styles . some ( s => s . scoped )
42
+ const hasCssModules = descriptor . styles . some ( s => s . module )
43
43
const hasFunctional =
44
44
descriptor . template && descriptor . template . attrs . functional
45
45
@@ -179,7 +179,7 @@ async function genTemplateCode(
179
179
return 'const _sfc_render = null; const _sfc_staticRenderFns = null'
180
180
}
181
181
182
- const hasScoped = descriptor . styles . some ( ( style ) => style . scoped )
182
+ const hasScoped = descriptor . styles . some ( style => style . scoped )
183
183
184
184
// If the template is not using pre-processor AND is not using external src,
185
185
// compile and inline it directly in the main module. When served in vite this
@@ -235,10 +235,17 @@ async function genScriptCode(
235
235
( ! script . lang || ( script . lang === 'ts' && options . devServer ) ) &&
236
236
! script . src
237
237
) {
238
+ const userPlugins = options . script ?. babelParserPlugins || [ ]
239
+ const defaultPlugins =
240
+ script . lang === 'ts'
241
+ ? userPlugins . includes ( 'decorators' )
242
+ ? ( [ 'typescript' ] as const )
243
+ : ( [ 'typescript' , 'decorators-legacy' ] as const )
244
+ : [ ]
238
245
scriptCode = options . compiler . rewriteDefault (
239
246
script . content ,
240
247
'_sfc_main' ,
241
- script . lang === 'ts' ? [ 'typescript' ] : undefined
248
+ [ ... defaultPlugins , ... userPlugins ]
242
249
)
243
250
map = script . map
244
251
} else {
0 commit comments