@@ -27,6 +27,7 @@ const noopLifecycle = {
2727function makeResolved ( overrides ?: {
2828 readonly targets ?: readonly string [ ]
2929 readonly name ?: string
30+ readonly autoloadDotenv ?: boolean
3031} ) : Parameters < typeof compile > [ 0 ] [ 'resolved' ] {
3132 return {
3233 entry : '/project/src/index.ts' ,
@@ -42,6 +43,7 @@ function makeResolved(overrides?: {
4243 define : { } ,
4344 } ,
4445 compile : {
46+ autoloadDotenv : overrides ?. autoloadDotenv ?? false ,
4547 targets : ( overrides ?. targets ?? [ ] ) as readonly CompileTarget [ ] ,
4648 name : overrides ?. name ?? 'cli' ,
4749 } ,
@@ -257,6 +259,62 @@ describe('compile operation', () => {
257259 expect ( stepFinishes ) . toContain ( 'linux-x64' )
258260 } )
259261
262+ it ( 'should always pass --no-compile-autoload-bunfig' , async ( ) => {
263+ await compile ( {
264+ resolved : makeResolved ( { targets : [ 'linux-x64' ] , name : 'my-app' } ) ,
265+ lifecycle : noopLifecycle ,
266+ } )
267+
268+ expect ( mockProcessExec ) . toHaveBeenCalledWith ( {
269+ cmd : 'bun' ,
270+ args : expect . arrayContaining ( [ '--no-compile-autoload-bunfig' ] ) ,
271+ cwd : '/project' ,
272+ } )
273+ } )
274+
275+ it ( 'should pass --no-compile-autoload-dotenv by default when autoloadDotenv is not configured' , async ( ) => {
276+ await compile ( {
277+ resolved : makeResolved ( { targets : [ 'linux-x64' ] , name : 'my-app' } ) ,
278+ lifecycle : noopLifecycle ,
279+ } )
280+
281+ expect ( mockProcessExec ) . toHaveBeenCalledWith ( {
282+ cmd : 'bun' ,
283+ args : expect . arrayContaining ( [ '--no-compile-autoload-dotenv' ] ) ,
284+ cwd : '/project' ,
285+ } )
286+ } )
287+
288+ it ( 'should pass --no-compile-autoload-dotenv when autoloadDotenv is explicitly false' , async ( ) => {
289+ await compile ( {
290+ resolved : makeResolved ( { targets : [ 'linux-x64' ] , name : 'my-app' , autoloadDotenv : false } ) ,
291+ lifecycle : noopLifecycle ,
292+ } )
293+
294+ expect ( mockProcessExec ) . toHaveBeenCalledWith ( {
295+ cmd : 'bun' ,
296+ args : expect . arrayContaining ( [ '--no-compile-autoload-dotenv' ] ) ,
297+ cwd : '/project' ,
298+ } )
299+ } )
300+
301+ it ( 'should not pass --no-compile-autoload-dotenv when autoloadDotenv is true' , async ( ) => {
302+ await compile ( {
303+ resolved : makeResolved ( {
304+ targets : [ 'linux-x64' ] ,
305+ name : 'my-app' ,
306+ autoloadDotenv : true ,
307+ } ) ,
308+ lifecycle : noopLifecycle ,
309+ } )
310+
311+ expect ( mockProcessExec ) . toHaveBeenCalledWith ( {
312+ cmd : 'bun' ,
313+ args : expect . not . arrayContaining ( [ '--no-compile-autoload-dotenv' ] ) ,
314+ cwd : '/project' ,
315+ } )
316+ } )
317+
260318 it ( 'should invoke bun with --compile and --outfile args' , async ( ) => {
261319 await compile ( {
262320 resolved : makeResolved ( { name : 'my-app' } ) ,
0 commit comments