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'
99const scriptSetupRE = / < s c r i p t \s ( .* \s ) ? s e t u p ( \s .* ) ? > /
1010
1111export function shouldTransform ( code : string , id : string , options ?: ScriptSetupTransformOptions ) : boolean {
12+ // avoid transforming twice
13+ if ( code . includes ( 'export default __sfc_main' ) )
14+ return false
1215 return ( options ?. refTransform && shouldTransformRefSugar ( code ) ) || scriptSetupRE . test ( code )
1316}
1417
Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ describe('transform', () => {
1919 const warn = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } )
2020
2121 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 )
2327
2428 warn . mockRestore ( )
2529 } )
You can’t perform that action at this time.
0 commit comments