rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[api-extractor] Allow multiple entrypoints

Open mkilpatrick opened this issue 3 years ago • 5 comments
trafficstars

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.

mkilpatrick avatar Jul 28 '22 14:07 mkilpatrick

Relevant:

  • https://github.com/microsoft/rushstack/issues/1596
  • https://github.com/microsoft/rushstack/pull/1932

zelliott avatar Jul 30 '22 17:07 zelliott

dupe of https://github.com/microsoft/rushstack/issues/3274 as well.

dzearing avatar Mar 15 '23 19:03 dzearing

Is additionalEntryPoints suppose to allow this:

https://github.com/microsoft/rushstack/blob/main/build-tests/api-extractor-scenarios/src/runScenarios.ts#L100

vjpr avatar Apr 16 '23 17:04 vjpr

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",

derekdon avatar Jan 17 '24 17:01 derekdon

Is additionalEntryPoints suppose to allow this:

it feels like maybe but its not exposed to consumers it seems

runspired avatar Apr 28 '24 19:04 runspired