diff --git a/validate_exports.js b/validate_exports.js index 9b73572..1b87200 100644 --- a/validate_exports.js +++ b/validate_exports.js @@ -27,13 +27,31 @@ async function validateExports() { for (const file of jsFiles) { const content = await fs.readFile(path.join(srcDir, file), 'utf-8'); - // Extract exports (including generator functions) - const exportMatches = content.match(/export\s+(?:async\s+)?(?:function\*?|const|let|var|class)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g); - if (exportMatches) { - const exports = exportMatches.map(match => { + // Extract exports (including generator functions and destructured exports) + const exports = []; + + // Match named exports: export function/const/let/var/class + const namedExportMatches = content.match(/export\s+(?:async\s+)?(?:function\*?|const|let|var|class)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g); + if (namedExportMatches) { + namedExportMatches.forEach(match => { const parts = match.split(/\s+/); - return parts[parts.length - 1]; + exports.push(parts[parts.length - 1]); }); + } + + // Match destructured exports: export { name1, name2 } + const destructuredExportMatches = content.match(/export\s*{\s*([^}]+)\s*}/g); + if (destructuredExportMatches) { + destructuredExportMatches.forEach(match => { + const namesMatch = match.match(/export\s*{\s*([^}]+)\s*}/); + if (namesMatch) { + const names = namesMatch[1].split(',').map(name => name.trim().split(/\s+as\s+/)[0].trim()); + exports.push(...names); + } + }); + } + + if (exports.length > 0) { exportMap.set(file, exports); }