MCPcopy
hub / github.com/vitejs/vite / prepareRolldownScanner

Function prepareRolldownScanner

packages/vite/src/node/optimizer/scan.ts:258–304  ·  view source on GitHub ↗
(
  environment: ScanEnvironment,
  entries: string[],
  deps: Record<string, string>,
  missing: Record<string, string>,
)

Source from the content-addressed store, hash-verified

256}
257
258async 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
306function orderedDependencies(deps: Record<string, string>) {
307 const depsList = Object.entries(deps)

Callers 1

scanFunction · 0.85

Calls 5

deepCloneFunction · 0.90
getRollupJsxPresetsFunction · 0.90
asyncFlattenFunction · 0.90
arraifyFunction · 0.90
rolldownScanPluginFunction · 0.85

Tested by

no test coverage detected