docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
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'))/**
* 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.