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

Bundle Stats Customizer

Build a tool that configures webpack bundle analysis to generate customized stats files with specific information included or excluded based on requirements.

Task

Create a function that generates a webpack configuration with the bundle analyzer plugin configured to produce stats files with custom options. The function should accept options for what to include in the stats output and return a properly configured plugin instance.

Requirements

Your implementation should:

  1. Accept a configuration object specifying which stats information to include/exclude (e.g., source code, reasons, chunks, modules, assets)
  2. Create a BundleAnalyzerPlugin instance with appropriate stats options
  3. Configure the plugin to generate a stats file with the specified options
  4. Support enabling/disabling source code inclusion in the stats file
  5. Allow control over whether module dependency reasons are included
  6. Return a properly configured plugin instance ready for use in webpack config

Test Cases

  • When configured to exclude source code, the generated stats file should not contain module source @test
  • When configured to include dependency reasons, the stats should contain reason information for modules @test
  • The plugin should generate a stats file with the specified filename @test
  • Multiple stats options can be configured simultaneously (e.g., exclude source, include reasons, include chunks) @test

Implementation

@generates

API

/**
 * Creates a configured BundleAnalyzerPlugin with custom stats options
 * @param {Object} config - Configuration for stats generation
 * @param {boolean} config.includeSource - Whether to include module source code in stats
 * @param {boolean} config.includeReasons - Whether to include module inclusion reasons
 * @param {boolean} config.includeChunks - Whether to include chunk information
 * @param {boolean} config.includeModules - Whether to include module information
 * @param {boolean} config.includeAssets - Whether to include asset information
 * @param {string} config.statsFilename - Filename for the generated stats file
 * @returns {BundleAnalyzerPlugin} Configured plugin instance
 */
function createBundleStatsPlugin(config) {
  // Implementation
}

module.exports = { createBundleStatsPlugin };

Dependencies { .dependencies }

webpack-bundle-analyzer { .dependency }

Provides webpack plugin for bundle analysis and stats generation.

@satisfied-by

Install with Tessl CLI

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

tile.json