CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-rollup-plugin-sizes

Show info about files/packages included with your rollup bundle

94

1.09x
Overview
Eval results
Files

task.mdevals/scenario-7/

Bundle Analyzer with Detailed File Reporting

Build a Rollup plugin that analyzes bundle composition and provides detailed file-level breakdowns when requested. The plugin should help developers understand which individual files within packages contribute to bundle size.

Requirements

Basic Analysis

The plugin must analyze bundles during the build process and provide a summary report showing package-level size information. The report should:

  • Display each package/module category with its total size
  • Show sizes in human-readable format (KB, MB, etc.)
  • Calculate and display the percentage each package contributes to the total bundle
  • Sort packages by size in descending order (largest first)

Detailed File Breakdown

When detailed reporting is enabled, the plugin must show individual file information within each package:

  • List all files included from each package
  • Display the size of each individual file
  • Show what percentage each file contributes to its parent package's total size
  • Sort files by size within each package (largest first)
  • Use indentation or visual hierarchy to show the relationship between packages and their files

Configuration

The plugin should support configuration options to control its behavior:

  • A flag to enable or disable detailed file-level reporting
  • Support for custom reporting functions that receive structured analysis data

Integration

The plugin must integrate properly with Rollup's build process:

  • Export a function that returns a valid Rollup plugin object
  • Hook into the appropriate phase of the bundle generation lifecycle
  • Handle multiple bundle configurations (single entry, array of entries, object of entries)

Implementation

@generates

API

/**
 * Creates a bundle analyzer plugin for Rollup
 * @param {Object} options - Configuration options
 * @param {boolean} [options.details=false] - Enable detailed file-level breakdown
 * @param {Function} [options.report] - Custom report function receiving analysis data
 * @returns {Object} Rollup plugin object
 */
function bundleAnalyzer(options = {}) {
  // Implementation
}

module.exports = bundleAnalyzer;

Test Cases

Basic Package Reporting

  • Given a bundle with modules from different packages, the plugin outputs a report showing each package name with its total size and percentage @test
  • Given a bundle, packages in the report are sorted by size in descending order @test

Detailed File Breakdown

  • When details option is enabled, the plugin outputs individual file paths and sizes for each package @test
  • When details option is enabled, files within each package are sorted by size in descending order @test

Configuration Options

  • When a custom report function is provided, it receives structured data with package totals and file details @test
  • The details option defaults to false when not specified @test

Dependencies { .dependencies }

Bundle Size Analysis Library { .dependency }

Provides bundle size analysis and reporting capabilities for Rollup builds.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-rollup-plugin-sizes

tile.json