@@ -31,15 +31,15 @@ export async function transformMain(
3131 const { descriptor, errors } = createDescriptor ( filename , code , options )
3232
3333 if ( errors . length ) {
34- errors . forEach ( ( error ) =>
34+ errors . forEach ( error =>
3535 pluginContext . error ( createRollupError ( filename , error ) )
3636 )
3737 return null
3838 }
3939
4040 // 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 )
4343 const hasFunctional =
4444 descriptor . template && descriptor . template . attrs . functional
4545
@@ -179,7 +179,7 @@ async function genTemplateCode(
179179 return 'const _sfc_render = null; const _sfc_staticRenderFns = null'
180180 }
181181
182- const hasScoped = descriptor . styles . some ( ( style ) => style . scoped )
182+ const hasScoped = descriptor . styles . some ( style => style . scoped )
183183
184184 // If the template is not using pre-processor AND is not using external src,
185185 // compile and inline it directly in the main module. When served in vite this
@@ -235,10 +235,17 @@ async function genScriptCode(
235235 ( ! script . lang || ( script . lang === 'ts' && options . devServer ) ) &&
236236 ! script . src
237237 ) {
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+ : [ ]
238245 scriptCode = options . compiler . rewriteDefault (
239246 script . content ,
240247 '_sfc_main' ,
241- script . lang === 'ts' ? [ 'typescript' ] : undefined
248+ [ ... defaultPlugins , ... userPlugins ]
242249 )
243250 map = script . map
244251 } else {
0 commit comments