rushstack
rushstack copied to clipboard
[api-extractor] Allow multiple entrypoints
mainEntryPointFilePath only allows a single entrypoint.
Let's say I have a repo that has multiple exports and types:
"exports": {
".": "./dist/index.js",
"./foo": "./dist/foo/foo.js",
"./util": "./dist/util/index.js"
},
"typesVersions": {
"*": {
"*": [
"dist/types/src/index.d.ts"
],
"foo": [
"dist/types/src/foo/index.d.ts"
],
"util": [
"dist/types/src/util/index.d.ts"
]
}
},
I can't generate correct docs based on this. The only thing you can do is export all types at the root, but that is incorrect for this project structure.
Relevant:
- https://github.com/microsoft/rushstack/issues/1596
- https://github.com/microsoft/rushstack/pull/1932
dupe of https://github.com/microsoft/rushstack/issues/3274 as well.
Is additionalEntryPoints suppose to allow this:
https://github.com/microsoft/rushstack/blob/main/build-tests/api-extractor-scenarios/src/runScenarios.ts#L100
Be great to get an official steer on this.
In the meantime, I've created a single entry point in src that exports all the package.json exports which works for now:
// ./src/index.docs.ts
/**
* API Docs index. This is used by api-extractor given our package.json exports.
* Monitoring: https://github.com/microsoft/rushstack/issues/3557
*/
export * from './index';
export * from './exportA';
export * from './exportB';
...and reference that instead as the mainEntryPointFilePath.
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../api-extractor.json",
"mainEntryPointFilePath": "<projectFolder>/dist/dts/index.docs.d.ts"
}
Tried and failed on various workarounds.
Invalid schema. I think additionalEntryPoints is a cmd line option, but not sure it's really exposed / works.
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../api-extractor.json",
"additionalEntryPoints": [
{
"modulePath": "exportA",
"filePath": "<projectFolder>/dist/dts/exportA/index.d.ts"
},
{
"modulePath": "exportB",
"filePath": "<projectFolder>/dist/dts/exportB/index.d.ts"
}
]
}
Not a valid node_module or something to that effect.
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../api-extractor.json",
"bundledPackages": ["<projectFolder>/dist/dts/exportA/index.d.ts", "<projectFolder>/dist/dts/exportB/index.d.ts"]
}
The root api-extractor.json file contains a standard mainEntryPointFilePath, which is:
"mainEntryPointFilePath": "<projectFolder>/dist/dts/index.d.ts",
Is additionalEntryPoints suppose to allow this:
it feels like maybe but its not exposed to consumers it seems