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

Bundle Size Analyzer

A Node.js utility that analyzes webpack bundle statistics and extracts comprehensive size metrics including stat, parsed, gzip, and brotli sizes.

Capabilities

Analyze bundle with multiple size types

  • Given a webpack stats file and bundle directory, the analyzer returns stat sizes for all JavaScript assets @test
  • Given a webpack stats file and bundle directory, the analyzer returns parsed sizes for all JavaScript assets @test
  • Given a webpack stats file and bundle directory with compressionAlgorithm set to 'gzip', the analyzer returns gzip compressed sizes @test
  • Given a webpack stats file and bundle directory with compressionAlgorithm set to 'brotli', the analyzer returns brotli compressed sizes @test

Handle errors gracefully

  • When the stats file path is invalid, an error is thrown @test

Implementation

@generates

API

/**
 * Analyzes webpack bundle statistics and returns comprehensive size metrics.
 *
 * @param {string} statsFilePath - Path to the webpack stats JSON file
 * @param {string} bundleDir - Directory containing the actual bundle files
 * @param {Object} options - Configuration options
 * @param {string} options.compressionAlgorithm - Compression algorithm to use ('gzip' or 'brotli')
 * @returns {Promise<Object>} Analysis result with the following structure:
 *   {
 *     chartData: Array of asset objects, each containing:
 *       - label: asset name
 *       - statSize: original input size in bytes
 *       - parsedSize: output size after transformations in bytes
 *       - gzipSize: gzip compressed size in bytes (if calculated)
 *   }
 * @throws {Error} If stats file cannot be read or parsed
 */
async function getBundleSizeMetrics(statsFilePath, bundleDir, options = {}) {
  // IMPLEMENTATION HERE
}

module.exports = {
  getBundleSizeMetrics,
};

Dependencies { .dependencies }

webpack-bundle-analyzer { .dependency }

Provides bundle analysis and size calculation capabilities for webpack stats files.

@satisfied-by

Install with Tessl CLI

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

tile.json