Commit 2900a9a 1 parent 167a9c3 commit 2900a9a Copy full SHA for 2900a9a
File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ async function genTemplateCode(
219
219
}
220
220
}
221
221
222
- const exportDefaultClassRE = / e x p o r t \s + d e f a u l t \s + c l a s s \s + ( [ \w $ ] + ) /
222
+ const exportDefaultClassRE = / (?: (?: ^ | \n | ; ) \s * ) e x p o r t \s + d e f a u l t \s + c l a s s \s + ( [ \w $ ] + ) /
223
223
224
224
async function genScriptCode (
225
225
descriptor : SFCDescriptor ,
@@ -240,11 +240,16 @@ async function genScriptCode(
240
240
( ! script . lang || ( script . lang === 'ts' && options . devServer ) ) &&
241
241
! script . src
242
242
) {
243
+ // TODO remove the class check logic after upgrading @vue /compiler-sfc
243
244
const classMatch = script . content . match ( exportDefaultClassRE )
244
245
if ( classMatch ) {
245
246
scriptCode =
246
247
script . content . replace ( exportDefaultClassRE , `class $1` ) +
247
248
`\nconst _sfc_main = ${ classMatch [ 1 ] } `
249
+ if ( / e x p o r t \s + d e f a u l t / . test ( scriptCode ) ) {
250
+ // fallback if there are still export default
251
+ scriptCode = rewriteDefault ( script . content , `_sfc_main` )
252
+ }
248
253
} else {
249
254
scriptCode = rewriteDefault ( script . content , `_sfc_main` )
250
255
}
You can’t perform that action at this time.
0 commit comments