or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-7/

Module Export Analyzer

Build a tool that analyzes CommonJS modules to detect and report transpiler-generated star re-export patterns. The tool should identify modules that re-export everything from other modules using patterns commonly generated by transpilers like TypeScript and Babel.

Requirements

Your analyzer should:

  1. Accept a JavaScript source code string as input
  2. Parse the source code to detect star re-export patterns
  3. Return a report containing:
    • A list of all modules being re-exported via star re-export patterns
    • A flag indicating whether any star re-export patterns were detected

Expected Behavior

  • Detect transpiler-generated patterns that re-export all exports from external modules
  • Correctly identify module specifiers from star re-export patterns
  • Handle multiple star re-export patterns in the same source file
  • Distinguish between regular named exports and star re-export patterns
  • Return an empty result when no star re-export patterns are present

Test Cases

  • When analyzing TypeScript-transpiled code containing __export(require("lodash")), detect "lodash" as a star re-export @test
  • When analyzing transpiled code containing __exportStar(require("./utils"), exports), detect "./utils" as a star re-export @test
  • When analyzing code with both __export(require("package-a")) and __exportStar(require("package-b"), exports), detect both "package-a" and "package-b" @test
  • When analyzing code with only regular exports like exports.name = value, return empty results indicating no star re-exports @test

Implementation

@generates

API

/**
 * Analyze CommonJS source code for star re-export patterns
 * @param {string} source - The JavaScript source code to analyze
 * @returns {Object} Analysis report with reexported modules and detection flag
 * @returns {string[]} return.modules - Array of module specifiers being star re-exported
 * @returns {boolean} return.hasStarExports - True if any star re-export patterns were detected
 */
function analyzeStarExports(source) {
  // Implementation here
}

module.exports = { analyzeStarExports };

Dependencies { .dependencies }

cjs-module-lexer { .dependency }

Provides lexical analysis of CommonJS modules to detect export patterns.

@satisfied-by