@@ -21,6 +21,11 @@ function transformArguments(argument: t.Node, s: MagicString, offset: number) {
2121 ) {
2222 s . appendLeft ( argument . start ! + offset , '$$(' )
2323 s . appendRight ( argument . end ! + offset , ')' )
24+ } else if (
25+ argument . type === 'FunctionExpression' ||
26+ argument . type === 'ArrowFunctionExpression'
27+ ) {
28+ transformFunctionReturn ( argument , s , offset )
2429 } else if ( argument . type === 'ArrayExpression' ) {
2530 argument . elements . forEach ( ( arg ) => {
2631 transformArguments ( arg ! , s , offset )
@@ -41,6 +46,23 @@ function transformArguments(argument: t.Node, s: MagicString, offset: number) {
4146 }
4247}
4348
49+ function transformFunctionReturn ( node : t . Node , s : MagicString , offset : number ) {
50+ if (
51+ node . type === 'FunctionDeclaration' ||
52+ node . type === 'FunctionExpression' ||
53+ node . type === 'ArrowFunctionExpression'
54+ )
55+ if ( node . body . type !== 'BlockStatement' ) {
56+ transformArguments ( node . body , s , offset )
57+ } else {
58+ node . body . body ?. forEach ( ( statement ) => {
59+ if ( statement . type === 'ReturnStatement' && statement . argument ) {
60+ transformArguments ( statement . argument , s , offset )
61+ }
62+ } )
63+ }
64+ }
65+
4466function transformReactivityFunction ( code : string , id : string ) {
4567 const lang = getLang ( id )
4668 let asts : {
0 commit comments