Home / File/ reporter.ts — vite Source File

reporter.ts — vite Source File

Architecture documentation for reporter.ts, a typescript file in the vite codebase. 20 imports, 1 dependents.

File typescript PluginSystem AssetManagement 20 imports 1 dependents 4 functions

Entity Profile

Dependency Diagram

graph LR
  a18c7381_7b31_1a3c_d997_50b979d5f107["reporter.ts"]
  5abb8c87_ffcb_f2d4_7421_e36705d9e5c7["plugin.ts"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 5abb8c87_ffcb_f2d4_7421_e36705d9e5c7
  dfa3f5a8_b519_cb65_4b7e_9d4824406fd4["perEnvironmentPlugin"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> dfa3f5a8_b519_cb65_4b7e_9d4824406fd4
  7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 7da774f9_eca5_d54e_6e01_6bee7d460a2b
  eb5604c2_58e1_1c00_5a1a_5d97ea5236ad["ResolvedConfig"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> eb5604c2_58e1_1c00_5a1a_5d97ea5236ad
  0c33ff62_54e9_5c90_902b_b26728e71fca["environment.ts"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 0c33ff62_54e9_5c90_902b_b26728e71fca
  7e6f7c83_3515_4e0d_5362_4eb9515b4a86["Environment"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 7e6f7c83_3515_4e0d_5362_4eb9515b4a86
  16a00926_f0e9_60f1_3006_9132a6d78745["perEnvironmentState"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 16a00926_f0e9_60f1_3006_9132a6d78745
  031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 031bc221_67a8_c579_f2bf_bb30a08beeb2
  3317449c_58e2_c090_7084_13d388f5a88a["isDefined"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 3317449c_58e2_c090_7084_13d388f5a88a
  50ac7e51_9f94_e985_bfec_ae95273b23b0["isInNodeModules"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 50ac7e51_9f94_e985_bfec_ae95273b23b0
  a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> a4adb1a7_cf54_091f_eb63_8217e684a8e1
  eca93de5_04d5_dda0_7ae6_2ceb5379ea81["logger.ts"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> eca93de5_04d5_dda0_7ae6_2ceb5379ea81
  abfc9e70_3c15_b3f0_a595_3cf27afb7e64["utils.ts"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> abfc9e70_3c15_b3f0_a595_3cf27afb7e64
  1a3bec7b_1a11_316f_5831_a0535b829bbf["withTrailingSlash"]
  a18c7381_7b31_1a3c_d997_50b979d5f107 --> 1a3bec7b_1a11_316f_5831_a0535b829bbf
  style a18c7381_7b31_1a3c_d997_50b979d5f107 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import path from 'node:path'
import { gzip } from 'node:zlib'
import { promisify } from 'node:util'
import colors from 'picocolors'
import type { OutputBundle } from 'rolldown'
import { viteReporterPlugin as nativeReporterPlugin } from 'rolldown/experimental'
import { type Plugin, perEnvironmentPlugin } from '../plugin'
import type { ResolvedConfig } from '../config'
import type { Environment } from '../environment'
import { perEnvironmentState } from '../environment'
import { isDefined, isInNodeModules, normalizePath } from '../utils'
import { LogLevels } from '../logger'
import { withTrailingSlash } from '../../shared/utils'

const groups = [
  { name: 'Assets', color: colors.green },
  { name: 'CSS', color: colors.magenta },
  { name: 'JS', color: colors.cyan },
]
type LogEntry = {
  name: string
  group: (typeof groups)[number]['name']
  size: number
  compressedSize: number | null
  mapSize: number | null
}

const COMPRESSIBLE_ASSETS_RE = /\.(?:html|json|svg|txt|xml|xhtml|wasm)$/

export function buildReporterPlugin(config: ResolvedConfig): Plugin {
  if (config.nativePluginEnabledLevel >= 1) {
    return perEnvironmentPlugin('native:reporter', (env) => {
      const tty = process.stdout.isTTY && !process.env.CI
      const shouldLogInfo =
        LogLevels[config.logLevel || 'info'] >= LogLevels.info
      const assetsDir = path.join(env.config.build.assetsDir, '/')
      return nativeReporterPlugin({
        root: env.config.root,
        isTty: !!tty,
        isLib: !!env.config.build.lib,
        assetsDir,
        chunkLimit: env.config.build.chunkSizeWarningLimit,
        shouldLogInfo,
        reportCompressedSize: env.config.build.reportCompressedSize,
        warnLargeChunks:
          env.config.build.minify &&
          !env.config.build.lib &&
          env.config.consumer === 'client',
      })
    })
  }

  const compress = promisify(gzip)

  const numberFormatter = new Intl.NumberFormat('en', {
    maximumFractionDigits: 2,
    minimumFractionDigits: 2,
  })
  const displaySize = (bytes: number) => {
    return `${numberFormatter.format(bytes / 1000)} kB`
// ... (329 more lines)

Domain

Subdomains

Types

Frequently Asked Questions

What does reporter.ts do?
reporter.ts is a source file in the vite codebase, written in typescript. It belongs to the PluginSystem domain, AssetManagement subdomain.
What functions are defined in reporter.ts?
reporter.ts defines 4 function(s): buildReporterPlugin, clearLine, throttle, writeLine.
What does reporter.ts depend on?
reporter.ts imports 20 module(s): Environment, ResolvedConfig, config.ts, environment.ts, experimental, isDefined, isInNodeModules, logger.ts, and 12 more.
What files import reporter.ts?
reporter.ts is imported by 1 file(s): build.ts.
Where is reporter.ts in the architecture?
reporter.ts is located at packages/vite/src/node/plugins/reporter.ts (domain: PluginSystem, subdomain: AssetManagement, directory: packages/vite/src/node/plugins).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free