import { SyntaxKind } from 'typescript';
const MODULE_REGEX = /import |export |module.exports|exports/;
const REQUIRE_REGEX = /require\(([a-zA-Z0-9])+\)/;
const EXPORT_REGEX = /export |module.exports|exports/;
const hasNodeGlobalImpact = (node) => node.kind === SyntaxKind.DeclareKeyword ? true : getNodes(node).some(hasNodeGlobalImpact);
const hasModules = ({ text }) => MODULE_REGEX.test(text) || REQUIRE_REGEX.test(text);
export const hasExports = ({ text }) => EXPORT_REGEX.test(text);
export const getNodes = (item) => {
    const nodes = [];
    item.forEachChild((node) => {
        nodes.push(node);
    });
    return nodes;
};
export const hasGlobalImpact = (sourceFile) => getNodes(sourceFile).some(hasNodeGlobalImpact) || !hasModules(sourceFile);
export const getDependencies = (sourceFile) => {
    const resolvedModules = sourceFile.resolvedModules;
    if (resolvedModules) {
        return Array.from(resolvedModules.values())
            .filter((resolved) => Boolean(resolved))
            .map((resolved) => resolved.resolvedFileName);
    }
    return [];
};
//# sourceMappingURL=dependencies.js.map