Home / Function/ buildReporterPlugin() — vite Function Reference

buildReporterPlugin() — vite Function Reference

Architecture documentation for the buildReporterPlugin() function in reporter.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0["buildReporterPlugin()"]
  a18c7381_7b31_1a3c_d997_50b979d5f107["reporter.ts"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|defined in| a18c7381_7b31_1a3c_d997_50b979d5f107
  8c4db194_5dfd_4391_cc9a_833655009196["resolveBuildPlugins()"]
  8c4db194_5dfd_4391_cc9a_833655009196 -->|calls| 573ab5b5_1ca7_8516_40b9_cab59ab7a7c0
  dfa3f5a8_b519_cb65_4b7e_9d4824406fd4["perEnvironmentPlugin()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| dfa3f5a8_b519_cb65_4b7e_9d4824406fd4
  16a00926_f0e9_60f1_3006_9132a6d78745["perEnvironmentState()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| 16a00926_f0e9_60f1_3006_9132a6d78745
  1da02f23_3691_1a34_a3f2_2801d80e06ce["throttle()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| 1da02f23_3691_1a34_a3f2_2801d80e06ce
  f918d4fd_9c62_b35c_336e_68b2ffd99411["writeLine()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| f918d4fd_9c62_b35c_336e_68b2ffd99411
  87ef2240_f0fc_b0c0_6743_d2186763d84b["clearLine()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| 87ef2240_f0fc_b0c0_6743_d2186763d84b
  a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| a4adb1a7_cf54_091f_eb63_8217e684a8e1
  1a3bec7b_1a11_316f_5831_a0535b829bbf["withTrailingSlash()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| 1a3bec7b_1a11_316f_5831_a0535b829bbf
  50ac7e51_9f94_e985_bfec_ae95273b23b0["isInNodeModules()"]
  573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 -->|calls| 50ac7e51_9f94_e985_bfec_ae95273b23b0
  style 573ab5b5_1ca7_8516_40b9_cab59ab7a7c0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/reporter.ts lines 30–363

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`
  }

  const tty = process.stdout.isTTY && !process.env.CI
  const shouldLogInfo = LogLevels[config.logLevel || 'info'] >= LogLevels.info

  const modulesReporter = shouldLogInfo
    ? perEnvironmentState((environment: Environment) => {
        let hasTransformed = false
        let transformedCount = 0

        const logTransform = throttle((id: string) => {
          writeLine(
            `transforming (${transformedCount}) ${colors.dim(
              path.relative(config.root, id),
            )}`,
          )
        })

        return {
          reset() {
            transformedCount = 0
          },
          register(id: string) {
            transformedCount++
            if (!tty) {
              if (!hasTransformed) {
                config.logger.info(`transforming...`)
              }
            } else {
              if (id.includes(`?`)) return
              logTransform(id)
            }
            hasTransformed = true
          },
          log() {
            if (tty) {
              clearLine()
            }
            environment.logger.info(
              `${colors.green(`✓`)} ${transformedCount} modules transformed.`,
            )
          },
        }
      })
    : undefined

  const chunksReporter = perEnvironmentState((environment: Environment) => {
    let hasRenderedChunk = false
    let hasCompressChunk = false
    let chunkCount = 0

Domain

Subdomains

Frequently Asked Questions

What does buildReporterPlugin() do?
buildReporterPlugin() is a function in the vite codebase, defined in packages/vite/src/node/plugins/reporter.ts.
Where is buildReporterPlugin() defined?
buildReporterPlugin() is defined in packages/vite/src/node/plugins/reporter.ts at line 30.
What does buildReporterPlugin() call?
buildReporterPlugin() calls 8 function(s): clearLine, isInNodeModules, normalizePath, perEnvironmentPlugin, perEnvironmentState, throttle, withTrailingSlash, writeLine.
What calls buildReporterPlugin()?
buildReporterPlugin() is called by 1 function(s): resolveBuildPlugins.

Analyze Your Own Codebase

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

Try Supermodel Free