CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-webpack-bundle-analyzer

Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap

Overall
score

98%

Overview
Eval results
Files

task.mdevals/scenario-7/

Bundle Size Analyzer

Create a utility that analyzes webpack bundle files to extract module size information and generate a summary report.

Requirements

Your task is to build a command-line tool that:

  1. Accepts a webpack stats file path as a command-line argument

  2. Analyzes the bundle data to extract module information

  3. Generates a JSON report containing:

    • Total number of modules found
    • List of the top 10 largest modules by parsed size (if available)
    • Total bundle size (parsed size)
    • A list of all chunk names in the bundle
  4. Writes the report to a file named bundle-report.json in the current directory

Input

The tool will receive a path to a webpack stats JSON file as the first command-line argument:

node src/analyzer.js path/to/stats.json

Output Format

The output file bundle-report.json should have this structure:

{
  "totalModules": 150,
  "totalBundleSize": 524288,
  "chunkNames": ["main", "vendor", "runtime"],
  "largestModules": [
    {
      "name": "./node_modules/some-library/index.js",
      "size": 45000
    },
    {
      "name": "./src/components/LargeComponent.js",
      "size": 32000
    }
  ]
}

Test Cases

  • Given a stats file from a simple webpack build with 5 modules, the tool correctly identifies all 5 modules and calculates the total size @test
  • Given a stats file with multiple chunks, the tool correctly extracts all chunk names @test
  • Given a stats file with more than 10 modules, the tool returns exactly 10 modules in the largestModules array, sorted by size descending @test

Implementation

@generates

Dependencies { .dependencies }

webpack-bundle-analyzer { .dependency }

Provides bundle analysis and parsing capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-webpack-bundle-analyzer

tile.json