Skip to content

feat(workspace-plugin): support export maps in generate-api and build executor#35997

Open
Hotell wants to merge 13 commits intomicrosoft:masterfrom
Hotell:tools/support-export-maps-for-generate-api
Open

feat(workspace-plugin): support export maps in generate-api and build executor#35997
Hotell wants to merge 13 commits intomicrosoft:masterfrom
Hotell:tools/support-export-maps-for-generate-api

Conversation

@Hotell
Copy link
Copy Markdown
Contributor

@Hotell Hotell commented Apr 16, 2026

Summary

Adds support for package.json exports map (sub-path and wildcard entries) in the generate-api executor, enabling packages like @fluentui/react-headless-components-preview to generate per-entry API reports and .d.ts rollups — fully automatically, without requiring additional api-extractor config files.

NOTE: this is OPT IN by default

How to opt in

Configure exportSubpaths on the generate-api target in project.json:

{
  "targets": {
    "generate-api": {
      "options": {
        "exportSubpaths": true
      }
    }
  }
}

NOTE: The workspace plugin reads this config and propagates it to the build target's generateApi option automatically. Nx merges everything into the executor options at runtime.

Make sure to set your export maps:

package.json:

{
  "exports": {
// 1. existing root barel definition
//   ".": {...},

// 2. your new sub-path API
    "./*": {
      "types": "./dist/components/*/index.d.ts",
      "node": "./lib-commonjs/components/*/index.js",
      "import": "./lib/components/*/index.js",
      "require": "./lib-commonjs/components/*/index.js"
    },
    "./utils": {
      "types": "./dist/utils/index.d.ts",
      "node": "./lib-commonjs/utils/index.js",
      "import": "./lib/utils/index.js",
      "require": "./lib-commonjs/utils/index.js"
     },
  },

// 3. update files to match your api output for types
"files": [
    // ...existing paths,
   // update .d.ts
    "dist/**/*.d.ts",    
  ],
}

Changes

generate-api executor

  • New exportSubpaths option (boolean | { apiReport?: boolean }) — when enabled, reads the package.json exports map and runs api-extractor for each resolved sub-path entry
  • Expand wildcard typed exports (e.g. ./*) into individual api-extractor runs per sub-directory
  • Expand named typed exports (e.g. ./utils) into individual api-extractor runs
  • Produces per-entry .d.ts rollups (under dist/) and API reports (under etc/)
  • All sub-path configs are generated programmatically — no additional api-extractor.*.json config files needed; the primary config's mainEntryPointFilePath is resolved and reused as declarationBase
  • Refactor: Extract small named functions (resolveDeclarationBase, parseWildcardTypesPattern, parseNamedTypesPattern, listSubDirectories, createSubpathEntryConfig, resolveConfigSource)
  • Shared utils.ts with isWildcardTypedEntry / isNamedTypedEntry helpers

build executor

  • Evolve generateApi from boolean to boolean | { exportSubpaths?: boolean | { apiReport?: boolean } } — backward compatible with existing true/false configs
  • When generateApi is an object, forward it as GenerateApiExecutorSchema to the generate-api executor

Workspace plugin

  • Read user's exportSubpaths from generate-api target options in project.json
  • Propagate generateApi: { exportSubpaths: <value> } to the build target so the build executor forwards it when calling generate-api internally
  • Use broad glob outputs (dist/**/*.d.ts, etc/*.api.md) when exportSubpaths is enabled

@github-actions
Copy link
Copy Markdown

Pull request demo site: URL

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

📊 Bundle size report

✅ No changes found

Hotell added 3 commits April 17, 2026 13:26
…of additional api-extractor configuration, remove initially boostrap nx generator which doesn't cover wilcards
@Hotell Hotell marked this pull request as ready for review April 17, 2026 14:44
@Hotell Hotell requested a review from a team as a code owner April 17, 2026 14:44
@Hotell Hotell changed the title feat(workspace-plugin): support export maps in generate-api executor feat(workspace-plugin): support export maps in generate-api and build executor Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant