( environment: ScanEnvironment, entries: string[], deps: Record<string, string>, missing: Record<string, string>, )
| 256 | } |
| 257 | |
| 258 | async function prepareRolldownScanner( |
| 259 | environment: ScanEnvironment, |
| 260 | entries: string[], |
| 261 | deps: Record<string, string>, |
| 262 | missing: Record<string, string>, |
| 263 | ): Promise<{ build: () => Promise<void> }> { |
| 264 | const { plugins: pluginsFromConfig = [], ...rolldownOptions } = |
| 265 | environment.config.optimizeDeps.rolldownOptions ?? {} |
| 266 | |
| 267 | const transformOptions = deepClone(rolldownOptions.transform) ?? {} |
| 268 | if (transformOptions.jsx === undefined) { |
| 269 | transformOptions.jsx = {} |
| 270 | } else if ( |
| 271 | transformOptions.jsx === 'react' || |
| 272 | transformOptions.jsx === 'react-jsx' |
| 273 | ) { |
| 274 | transformOptions.jsx = getRollupJsxPresets(transformOptions.jsx) |
| 275 | } |
| 276 | if (typeof transformOptions.jsx === 'object') { |
| 277 | transformOptions.jsx.development ??= !environment.config.isProduction |
| 278 | } |
| 279 | const transformSyncJsxOptions: OxcTransformOptions['jsx'] = |
| 280 | transformOptions.jsx === false ? undefined : transformOptions.jsx |
| 281 | |
| 282 | const plugins = await asyncFlatten(arraify(pluginsFromConfig)) |
| 283 | plugins.push( |
| 284 | ...rolldownScanPlugin( |
| 285 | environment, |
| 286 | deps, |
| 287 | missing, |
| 288 | entries, |
| 289 | transformSyncJsxOptions, |
| 290 | ), |
| 291 | ) |
| 292 | |
| 293 | async function build() { |
| 294 | await scan({ |
| 295 | ...rolldownOptions, |
| 296 | transform: transformOptions, |
| 297 | input: entries, |
| 298 | logLevel: 'silent', |
| 299 | plugins, |
| 300 | }) |
| 301 | } |
| 302 | |
| 303 | return { build } |
| 304 | } |
| 305 | |
| 306 | function orderedDependencies(deps: Record<string, string>) { |
| 307 | const depsList = Object.entries(deps) |
no test coverage detected