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 module source code and reports on the module's exported names and any module reexports it contains.
Your tool should provide a function that:
module.exports = require('./other'))The tool should handle various CommonJS export patterns including:
exports.foo = ...module.exports.bar = ...module.exports = { a, b, c }module.exports = require('./another-module')"exports.foo = 'bar';", the function returns { exports: ['foo'], reexports: [] } @test"module.exports = { a: 1, b: 2 };", the function returns an object with exports containing 'a' and 'b' @test"module.exports = require('./other');", the function returns an object with reexports containing './other' @test/**
* Analyzes CommonJS module source code and extracts export information
* @param {string} sourceCode - The JavaScript source code to analyze
* @returns {Promise<{exports: string[], reexports: string[]}>} Object containing arrays of exports and reexports
*/
async function analyzeModule(sourceCode) {
// Implementation here
}
module.exports = { analyzeModule };Provides static analysis capabilities for CommonJS modules to detect named exports and reexports.