or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-5/

Module Export Batch Analyzer

A utility that processes multiple JavaScript files to extract CommonJS export information with optimal performance.

Capabilities

Extract Module Exports

You need to build a utility that analyzes JavaScript source code to extract CommonJS export information.

  • Given JavaScript source code as a string, the utility extracts the named exports from the code @test
  • Given JavaScript source code, the utility extracts the reexported module specifiers @test
  • The utility returns an object containing arrays of exports and reexports @test

Optimize Performance

The utility should be optimized for parsing performance, especially when analyzing multiple files sequentially.

  • The utility properly initializes the parsing engine before processing files @test
  • When processing multiple files sequentially, the utility maintains good performance across all files @test

Handle Parse Errors

  • If the JavaScript source contains syntax errors, the utility returns error details including line and column information @test

Implementation

@generates

API

/**
 * Analyzes JavaScript source code and extracts CommonJS export information.
 *
 * @param {string} sourceCode - JavaScript source code to analyze
 * @returns {Promise<ExportInfo>} Export information or error details
 *
 * @typedef {Object} ExportInfo
 * @property {string[]} exports - Array of named exports found in the code
 * @property {string[]} reexports - Array of module specifiers that are reexported
 * @property {ParseError|null} error - Error information if parsing failed, null otherwise
 *
 * @typedef {Object} ParseError
 * @property {string} message - Error message
 * @property {number} line - Line number where error occurred
 * @property {number} column - Column number where error occurred
 */
async function analyzeModule(sourceCode) {
  // IMPLEMENTATION HERE
}

module.exports = {
  analyzeModule
};

Dependencies { .dependencies }

cjs-module-lexer { .dependency }

Provides high-performance lexical analysis of CommonJS modules to extract export information.

@satisfied-by