CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-cjs-module-lexer

High-performance CommonJS module lexer for detecting named exports and reexports from JavaScript source code

93

0.98x

Quality

Pending

Does it follow best practices?

Impact

93%

0.98x

Average score across 10 eval scenarios

Overview
Eval results
Files

task.mdevals/scenario-10/

Transpiled Module Analyzer

Build a tool that analyzes transpiled JavaScript modules to detect and identify star re-export patterns.

Overview

When TypeScript and Babel transpilers convert ESM star re-exports (export * from 'module') to CommonJS, they generate distinctive code patterns. Your task is to build an analyzer that detects these patterns and classifies which transpiler generated them.

Capabilities

Detect Babel patterns

  • Given source code with a Babel star re-export pattern (Object.keys forEach loop), returns { detected: true, transpiler: 'babel' } @test

Detect TypeScript patterns

  • Given source code with a TypeScript star re-export pattern (__export or __exportStar function), returns { detected: true, transpiler: 'typescript' } @test

Handle non-transpiled code

  • Given source code without star re-export patterns, returns { detected: false, transpiler: null } @test

Implementation

@generates

API

/**
 * Analyzes transpiled CommonJS code to detect star re-export patterns
 * @param {string} source - JavaScript source code to analyze
 * @returns {Object} Analysis result with detected (boolean) and transpiler (string|null) properties
 */
function analyzeTranspiledModule(source) {
  // Implementation here
}

module.exports = { analyzeTranspiledModule };

Dependencies { .dependencies }

cjs-module-lexer { .dependency }

Provides CommonJS module lexing and export detection capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-cjs-module-lexer

tile.json