11import { babelParse , getLang } from 'ast-kit'
2- import { generateTransform , MagicString } from 'magic -string-ast '
2+ import { withMagicString } from 'rolldown -string'
33import { createUnplugin , type UnpluginInstance } from 'unplugin'
44import { resolveOption , type Options } from './core/options'
55import { resolveName } from './core/utils'
@@ -28,8 +28,9 @@ export const VueNamedExport: UnpluginInstance<Options | undefined, false> =
2828 exclude : options . exclude ,
2929 } ,
3030 } ,
31- async handler ( code , id ) {
31+ handler : withMagicString ( async ( s , id ) => {
3232 const lang = getLang ( id )
33+ const code = s . toString ( )
3334
3435 const program = babelParse ( code , lang )
3536 const defaultExport = program . body . find (
@@ -38,7 +39,6 @@ export const VueNamedExport: UnpluginInstance<Options | undefined, false> =
3839 )
3940 if ( ! defaultExport ) return
4041
41- const s = new MagicString ( code )
4242 const resolvedName = await ( options . resolveName || resolveName ) ( id )
4343
4444 s . overwrite (
@@ -59,9 +59,7 @@ export const VueNamedExport: UnpluginInstance<Options | undefined, false> =
5959 `\nexport default ${ resolvedName } ;` ,
6060 )
6161 }
62-
63- return generateTransform ( s , id )
64- } ,
62+ } ) ,
6563 } ,
6664
6765 vite : {
0 commit comments