Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EngSys][generate-doc] add subpath exports support #31699

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion eng/tools/generate-doc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,27 @@ import { loadTheme } from "./theme/theme.js";
async function runTypeDoc({ outputFolder, cwd }: { outputFolder: string; cwd: string }) {
const oldCwd = process.cwd();
process.chdir(cwd);
const packageJsonPath = path.join(cwd, "package.json");
const content = await readFile(packageJsonPath, "utf-8");
const packageJson = JSON.parse(content);
let entryPoints = ["src/index.ts"];
const exports = packageJson["exports"];
if (exports) {
entryPoints = [];
for (const [key, value] of Object.entries(exports)) {
if (key === "./package.json") {
continue;
}
const sourcePath = (value as Record<string, any>)["import"]?.["default"];
if (sourcePath) {
entryPoints.push(sourcePath.replace("./dist/esm", "src").replace(".js", ".ts"));
}
}
}
console.log(` entrypoints: ${JSON.stringify(entryPoints)}`);
jeremymeng marked this conversation as resolved.
Show resolved Hide resolved

const app = await TypeDocApplication.bootstrap({
entryPoints: ["src/index.ts"],
entryPoints,
excludeInternal: true,
excludePrivate: true,
skipErrorChecking: true,
Expand Down