Home Reference Source
import {ProjextRollupStatsPlugin} from 'projext-plugin-rollup/src/plugins/stats/index.js'
public class | source

ProjextRollupStatsPlugin

This is a Rollup plugin that shows stats on the files generated and/or copied. The way this plugin works is kind of different: Once instantiated, it has an add metho for registering stats entries and that can be sent to other plugins; and at the same time, it has a log method that you would add as a plugin and it would show the entries.

Example:

const stats = new ProjextRollupStatsPlugin();
stats.add(...);
stats.add(...);
...
export { *   plugins: [
    commonjs(),
    resolve(),
    ...,
    stats.log(),
  ],
};

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

The name of the plugin's instance.

Method Summary

Public Methods
public

add(plugin: string | Promise, filepath: string, index: number)

Adds a new stats entry.

public

Gets the plugin options

public

Generates a "sub plugin" to add to the plugins queue and that will take care of logging all the added entries on a report table.

public

Generates a "sub plugin" to add to the plugins queue and that will reset the entries list.

Public Constructors

public constructor(options: ProjextRollupStatsPluginOptions, name: string) source

Params:

NameTypeAttributeDescription
options ProjextRollupStatsPluginOptions
  • optional
  • default: {}

The options to customize the plugin behaviour.

name string
  • optional
  • default: 'projext-rollup-plugin-node-stats'

The name of the plugin's instance.

Public Members

public name: string source

The name of the plugin's instance.

Public Methods

public add(plugin: string | Promise, filepath: string, index: number) source

Adds a new stats entry.

Params:

NameTypeAttributeDescription
plugin string | Promise

This can be either the name of the plugin generating the entry, or, if the spot should be saved but the actual entry is involved on an async task, a promise the plugin will wait for. The promise should be resolved with an object with the keys plugin and filepath.

filepath string
  • optional
  • nullable: true

The path for the file that was generatedcopied. This is not required if plugin is a promise.

index number
  • optional
  • default: null
  • nullable: true

If this value is specified, instead of adding the entry to the list, it will be set at the given index. This is used internally by the plugin after resolving promise based entries, instead of adding the resolved value, the plugin replaces the entry that had the promise with the resolved information.

public getOptions(): ProjextRollupStatsPluginOptions source

Gets the plugin options

public log(options: ProjextRollupStatsPluginLogOptions): ProjextRollupStatsPluginLog source

Generates a "sub plugin" to add to the plugins queue and that will take care of logging all the added entries on a report table.

Params:

NameTypeAttributeDescription
options ProjextRollupStatsPluginLogOptions
  • optional
  • default: {}

Custom options for the "sub plugin".

public reset(): ProjextRollupStatsPluginReset source

Generates a "sub plugin" to add to the plugins queue and that will reset the entries list. The reason this exists is because when Rollup is on "watch mode", the plugins can run more than once, and if the queue is not reseted, the report table will show the entries for ALL the times the plugin ran.