@routineless/nx-aws-cdk
Version:
Nx plugin for AWS CDK
59 lines • 2.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEntryPoints = void 0;
const tslib_1 = require("tslib");
const devkit_1 = require("@nx/devkit");
const glob = tslib_1.__importStar(require("fast-glob"));
const fs = tslib_1.__importStar(require("fs"));
const path = tslib_1.__importStar(require("path"));
function getEntryPoints(projectName, context, options = {}) {
const entryPoints = options.initialEntryPoints ? new Set(options.initialEntryPoints) : new Set();
const seenProjects = new Set();
const findEntryPoints = (projectName, tsConfigFileName) => {
if (seenProjects.has(projectName))
return;
seenProjects.add(projectName);
const project = context.projectGraph?.nodes[projectName];
if (!project)
return;
// Known files we generate from our generators. Only one of these should be used to build the project.
const tsconfigCandidates = ['tsconfig.app.json', 'tsconfig.lib.json', 'tsconfig.json'];
if (tsConfigFileName)
tsconfigCandidates.unshift(tsConfigFileName);
const foundTsConfig = tsconfigCandidates.find((f) => {
try {
return fs.statSync(path.join(project.data.root, f)).isFile();
}
catch {
return false;
}
});
// Workspace projects may not be a TS project, so skip reading source files if tsconfig is not found.
if (foundTsConfig) {
const tsconfig = (0, devkit_1.readJsonFile)(path.join(project.data.root, foundTsConfig));
const projectFiles = glob
.sync(tsconfig.include ?? [], {
cwd: project.data.root,
ignore: tsconfig.exclude ?? [],
})
.map((f) => path.join(project.data.root, f));
projectFiles.forEach((f) => entryPoints.add(f));
options?.onProjectFilesMatched?.(projectName, projectFiles);
}
if (options.recursive) {
const deps = context.projectGraph.dependencies[projectName] || [];
deps.forEach((dep) => {
if (context.projectGraph.nodes[dep.target]) {
if (options.excludeImplicit && dep.type === 'implicit') {
return;
}
findEntryPoints(dep.target);
}
});
}
};
findEntryPoints(projectName, options.initialTsConfigFileName);
return Array.from(entryPoints);
}
exports.getEntryPoints = getEntryPoints;
//# sourceMappingURL=esbuild.js.map