@@ -1179,6 +1179,26 @@ describe('@knighted/module', () => {
11791179 assert . equal ( ( mod as any ) . bar ( ) , 'bar' )
11801180 } )
11811181
1182+ it ( 'emits shorthand exports when names match' , async t => {
1183+ const fixturePath = join ( fixtures , 'idiomaticShorthand.cjs' )
1184+ const outFile = join ( fixtures , 'idiomaticShorthand.mjs' )
1185+
1186+ t . after ( ( ) => rm ( outFile , { force : true } ) )
1187+
1188+ const result = await transform ( fixturePath , { target : 'module' } )
1189+ await writeFile ( outFile , result )
1190+
1191+ assert . equal ( result . includes ( '__exports' ) , false )
1192+ assert . ok ( result . includes ( 'export { example };' ) )
1193+ assert . equal ( result . includes ( ';;' ) , false )
1194+
1195+ const { status } = spawnSync ( 'node' , [ outFile ] , { stdio : 'inherit' } )
1196+ assert . equal ( status , 0 )
1197+
1198+ const mod = await import ( pathToFileURL ( outFile ) . href )
1199+ assert . equal ( ( mod as any ) . example ( ) , 'ok' )
1200+ } )
1201+
11821202 it ( 'respects idiomaticExports: off and keeps helper bag' , async t => {
11831203 const fixturePath = join ( fixtures , 'idiomaticSafe.cjs' )
11841204 const outFile = join ( fixtures , 'idiomaticOff.mjs' )
0 commit comments