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

Module Path Resolver

Build a utility that resolves and displays module file paths relative to their entry point directories, similar to how bundler analysis tools present module information.

Requirements

Your implementation should process module information from a bundler and output relative paths for application files based on the entry point location. The tool should handle multiple entry points and maintain correct path relationships.

Input Processing

Handle module data that includes:

  • Absolute file paths for each module
  • Entry point file paths (single or multiple)
  • Module categories (e.g., "app", "npm", "helpers")

Path Resolution Logic

For modules in the "app" category:

  • Calculate the base directory from each entry point using the directory containing the entry file
  • Convert absolute module paths to relative paths from the appropriate base directory
  • Match each module to the correct base directory when multiple entry points exist

For other module categories:

  • Preserve the module identifier as-is (no path transformation needed)

Output Format

Display resolved module information showing:

  • Module identifier (relative path for app modules, original identifier for others)
  • Category type
  • Associated entry point

Test Cases

  • When given entry point "/project/src/main.js" and module "/project/src/components/App.js", the base directory should be "/project/src" and the relative path should be "components/App.js" @test

  • When given multiple entry points ["/project/src/app.js", "/project/admin/index.js"] and modules from both locations, each module should resolve relative to its corresponding base directory @test

  • When given entry points as object {app: "/project/src/app.js", admin: "/project/admin/index.js"}, the resolution should match modules to the correct base directory by entry point @test

  • For npm package modules like "lodash" or helper modules, the identifier should remain unchanged regardless of entry point @test

@generates

API

/**
 * Resolves module paths relative to their entry point base directories
 * @param {Object} config - Configuration object
 * @param {string|string[]|Object} config.entryPoints - Entry point(s) for the bundle
 * @param {Array} config.modules - Array of module objects with {id, category} properties
 * @returns {Array} Array of resolved module objects with {identifier, category, baseDir} properties
 */
function resolveModulePaths(config) {
  // Implementation here
}

module.exports = { resolveModulePaths };

Dependencies { .dependencies }

rollup-plugin-sizes { .dependency }

Bundle size analysis plugin that demonstrates base directory management for module path resolution.

path { .dependency }

Provides path manipulation utilities for directory and relative path operations.

Install with Tessl CLI

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

tile.json