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-9/

Bundle Package Size Analyzer

Create a Rollup plugin that analyzes bundle composition and reports which packages contribute to the bundle size. The plugin should aggregate module sizes by their package name and display a sorted breakdown showing each package's contribution to the total bundle size.

Requirements

  1. Plugin Implementation

    • Export a function that returns a Rollup plugin object
    • The plugin should hook into the appropriate Rollup build phase to access bundle information
    • Name the plugin appropriately
  2. Package Categorization

    • Identify which modules come from npm packages (node_modules)
    • Group application code under a category called "app"
    • Handle Rollup's internal helper code appropriately
  3. Size Aggregation

    • Calculate the total size of all modules belonging to each package
    • Aggregate sizes by summing all files from the same package
    • Track the overall total bundle size
  4. Output Report

    • Display results to the console showing each package name and its size
    • Include percentage of total bundle size for each package
    • Sort packages by size in descending order (largest first)
    • Format sizes in a human-readable way (e.g., KB, MB)

Dependencies { .dependencies }

rollup-plugin-sizes { .dependency }

A Rollup plugin for analyzing and reporting bundle size composition by package.

rollup { .dependency }

Module bundler for JavaScript applications.

Test Cases

Test 1: Single Entry Bundle @test

Input: Rollup configuration with a single entry point that imports multiple npm packages and local application files.

Expected Output:

  • Console output showing a size breakdown with package names
  • Each package listed with its size and percentage
  • Packages sorted from largest to smallest
  • Total bundle size displayed

Test 2: Multi-Entry Bundle @test

Input: Rollup configuration with multiple entry points (array format).

Expected Output:

  • Separate size reports for each bundle
  • Each report showing package breakdown specific to that bundle
  • Correct sizes and percentages for each entry point's dependencies

Install with Tessl CLI

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

tile.json