@@ -7,6 +7,7 @@ import { glob } from 'tinyglobby'
77import { build , type Options } from '../src/index'
88import type { RollupLog } from 'rolldown'
99import type { RunnerTask , TestContext } from 'vitest'
10+ import { mergeUserOptions } from '../src/options'
1011
1112const dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1213const tmpDir = path . resolve ( dirname , 'temp' )
@@ -132,22 +133,33 @@ export async function testBuild({
132133 const workingDir = path . join ( testDir , cwd || '.' )
133134 const restoreCwd = chdir ( workingDir )
134135 const warnings : RollupLog [ ] = [ ]
136+ const userOptions =
137+ typeof options === 'function' ? options ( workingDir ) : options
135138 const resolvedOptions : Options = {
136139 entry : 'index.ts' ,
137140 config : false ,
138141 outDir : 'dist' ,
139142 dts : false ,
140143 silent : true ,
141- inputOptions : {
142- onLog ( level , log , defaultHandler ) {
143- if ( level === 'warn' ) {
144- warnings . push ( log )
145- return
146- }
147- defaultHandler ( level , log )
148- } ,
144+ ...userOptions ,
145+ async inputOptions ( options , ...args ) {
146+ options = await mergeUserOptions (
147+ {
148+ ...options ,
149+ onLog ( level , log , defaultHandler ) {
150+ if ( level === 'warn' ) {
151+ warnings . push ( log )
152+ return
153+ }
154+ defaultHandler ( level , log )
155+ } ,
156+ logLevel : 'info' ,
157+ } ,
158+ userOptions ?. inputOptions ,
159+ args ,
160+ )
161+ return options
149162 } ,
150- ...( typeof options === 'function' ? options ( workingDir ) : options ) ,
151163 }
152164 await beforeBuild ?.( )
153165 await build ( resolvedOptions )
0 commit comments