This repository was archived by the owner on Dec 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ import { resolveOptions } from './options'
9
9
const scriptSetupRE = / < s c r i p t \s ( .* \s ) ? s e t u p ( \s .* ) ? > /
10
10
11
11
export function shouldTransform ( code : string , id : string , options ?: ScriptSetupTransformOptions ) : boolean {
12
+ // avoid transforming twice
13
+ if ( code . includes ( 'export default __sfc_main' ) )
14
+ return false
12
15
return ( options ?. refTransform && shouldTransformRefSugar ( code ) ) || scriptSetupRE . test ( code )
13
16
}
14
17
Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ describe('transform', () => {
19
19
const warn = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } )
20
20
21
21
const fixture = await fs . readFile ( resolve ( root , file ) , 'utf-8' )
22
- expect ( transform ( fixture , file , { refTransform : true } ) ?. code || fixture ) . toMatchSnapshot ( )
22
+ const result = transform ( fixture , file , { refTransform : true } ) ?. code || fixture
23
+ expect ( result ) . toMatchSnapshot ( )
24
+
25
+ const result2 = transform ( result , file , { refTransform : true } ) ?. code || result
26
+ expect ( result ) . toEqual ( result2 )
23
27
24
28
warn . mockRestore ( )
25
29
} )
You can’t perform that action at this time.
0 commit comments