CC 4.0 License

The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.

The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.

Stats

Generate packaging information that can be used to analyze module dependencies and optimize compilation speed.

Output JSON file of stats
  • Using @rspack/cli, rspack build --json stats.json.
  • Using rspack's Node.js API, stats.toJson(options)stats.toString(options).
  • Type: boolean | string | Object
  • Default: {"preset":"errors-warnings","timings":true}

Stats Presets

Preset Description
'normal' (true) Output by default value of stats options
'none' (false) Output nothing
'verbose' Output everything
'errors-only' Output only error-related information
'errors-warnings' Output only error and warning related information

Stats Options

You can specify exactly which packing information to output, all the following fields are optional.

stats.assets

  • Type: boolean
  • Default: true

Tells stats whether to show the asset information.

stats.chunks

  • Type: boolean
  • Default: true

Tells stats whether to show the chunk information.

stats.modules

  • Type: boolean
  • Default: true

Tells stats whether to show the module information.

stats.entrypoints

  • Type: boolean
  • Default: true

Tells stats whether to show the entrypoints information.

stats.chunkGroups

  • Type: boolean
  • Default: true

Tells stats whether to add information about the namedChunkGroups.

stats.reasons

  • Type: boolean
  • Default: true

Tells stats to add information about the reasons of why modules are included.

stats.hash

  • Type: boolean
  • Default: true

Tells stats whether to add information about the hash of the compilation.

stats.errors

  • Type: boolean
  • Default: true

Tells stats whether to display the errors.

stats.errorsCount

  • Type: boolean
  • Default: true

Add errors count.

stats.warnings

  • Type: boolean
  • Default: true

Tells stats to add warnings.

stats.warningsCount

  • Type: boolean
  • Default: true

Add warnings count.

stats.colors

  • Type: boolean
  • Default: false

Tells stats whether to output in the different colors.

It is set to true by default when executing rspack build on environments with color support.

stats.version

  • Type: boolean
  • Default: true

Tells stats to add information about the Rspack version used.

stats.publicPath

  • Type: boolean
  • Default: true

Tells stats to show the publicPath.

stats.outputPath

  • Type: boolean
  • Default: true

Tells stats to show the outputPath.

stats.chunkModules

  • Type: boolean
  • Default: true

Tells stats whether to add information about the built modules to information about the chunk.

stats.chunkRelations

  • Type: boolean
  • Default: false

Tells stats to display chunk parents, children and siblings.

stats.ids

  • Type: boolean
  • Default: false

Tells stats to add IDs of modules and chunks.

stats.timings

  • Type: boolean
  • Default: true

Tells stats to add the timing information.

stats.builtAt

  • Type: boolean
  • Default: true

Tells stats whether to add the build date and the build time information. Set stats.builtAt to false to hide it.

stats.moduleAssets

  • Type: boolean
  • Default: true

Tells stats whether to add information about assets inside modules. Set stats.moduleAssets to false to hide it.

stats.modulesSpace

  • Type: number
  • Default: 15

Tells stats how many items of modules should be displayed (groups will be collapsed to fit this space).

stats.nestedModules

  • Type: boolean
  • Default: true

Tells stats whether to add information about modules nested in other modules (like with module concatenation).

stats.source

  • Type: boolean
  • Default: false

Tells stats to add the source code of modules.

stats.logging

  • Type: 'info' | 'none' | 'error' | 'warn' | 'log' | 'verbose' | boolean

Tells stats whether to add logging output.

stats.loggingDebug

  • Type: Array<string | RegExp | function (name) => boolean>

Tells stats to include the debug information of the specified loggers such as Plugins or Loaders. When stats.logging is set to false, stats.loggingDebug option is ignored.

rspack.config.js
module.exports = {
  //...
  stats: {
    loggingDebug: [
      'MyPlugin',
      /rspack/, // To get core logging
    ],
  },
};

stats.loggingTrace

  • Type: boolean

Enable stack traces in the logging output for errors, warnings and traces. Set stats.loggingTrace to hide the trace.

stats.children

  • Type: boolean

Tells stats whether to add information about the childCompiler.

stats.all

  • Type: boolean
  • Default: undefined

Controlling whether all stats options are output.

stats.preset

  • Type: boolean
  • Default: undefined

Output according to preset values.

Extending stats behaviours

If you want to use the preset output behavior but want to output more or less of individual fields, you can customize the output behavior of the fields after specifying preset or all.

For example, only the error and the reason why the module was introduced are output.

module.exports = {
  // ...
  stats: {
    preset: 'errors-only',
    reasons: true,
  },
};