@@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url'
5
5
import { expectFilesSnapshot } from '@sxzz/test-utils'
6
6
import { glob } from 'tinyglobby'
7
7
import { build , type Options } from '../src/index'
8
+ import type { RollupLog } from 'rolldown'
8
9
import type { RunnerTask , TestContext } from 'vitest'
9
10
10
11
const dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
@@ -123,18 +124,29 @@ export async function testBuild({
123
124
outputDir : string
124
125
snapshot : string
125
126
fileMap : Record < string , string >
127
+ warnings : RollupLog [ ]
126
128
} > {
127
129
const { expect } = context
128
130
const { testName, testDir } = await writeFixtures ( context , files , fixture )
129
131
130
132
const workingDir = path . join ( testDir , cwd || '.' )
131
133
const restoreCwd = chdir ( workingDir )
134
+ const warnings : RollupLog [ ] = [ ]
132
135
const resolvedOptions : Options = {
133
136
entry : 'index.ts' ,
134
137
config : false ,
135
138
outDir : 'dist' ,
136
139
dts : false ,
137
140
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
+ } ,
149
+ } ,
138
150
...( typeof options === 'function' ? options ( workingDir ) : options ) ,
139
151
}
140
152
await beforeBuild ?.( )
@@ -159,6 +171,7 @@ export async function testBuild({
159
171
outputDir,
160
172
snapshot,
161
173
fileMap,
174
+ warnings,
162
175
}
163
176
}
164
177
0 commit comments