High-performance CommonJS module lexer for detecting named exports and reexports from JavaScript source code
93
Quality
Pending
Does it follow best practices?
Impact
93%
0.98xAverage score across 10 eval scenarios
Build a tool that analyzes CommonJS JavaScript files to identify which modules are being reexported. This is useful for understanding module dependency chains and detecting proxy modules in a codebase.
Your tool should analyze JavaScript source code files and identify all module reexports - cases where a module directly forwards another module's exports without modification.
Create a function that:
module.exports = require('./other'))@generates
/**
* Analyzes JavaScript source code to detect module reexports
* @param {string} sourceCode - The JavaScript source code to analyze
* @returns {string[]} Array of module specifiers being reexported
*/
function analyzeReexports(sourceCode) {
// Implementation here
}
module.exports = { analyzeReexports };When given source code with a direct reexport module.exports = require('./utils'), it returns ['./utils'] @test
When given source code with object spread reexports module.exports = { ...require('lodash'), ...require('./helpers') }, it returns ['lodash', './helpers'] @test
When given source code with no reexports (only named exports like exports.foo = 'bar'), it returns an empty array @test
When given empty source code, it returns an empty array @test
Provides CommonJS module lexical analysis capabilities for detecting exports and reexports from JavaScript source code.
Install with Tessl CLI
npx tessl i tessl/npm-cjs-module-lexerdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10