feat(workspace-plugin): support export maps in generate-api and build executor#35997
Open
Hotell wants to merge 13 commits intomicrosoft:masterfrom
Open
feat(workspace-plugin): support export maps in generate-api and build executor#35997Hotell wants to merge 13 commits intomicrosoft:masterfrom
Hotell wants to merge 13 commits intomicrosoft:masterfrom
Conversation
…in small functions
|
Pull request demo site: URL |
…nerateApi config propagation from build->generate-api target
📊 Bundle size report✅ No changes found |
…of additional api-extractor configuration, remove initially boostrap nx generator which doesn't cover wilcards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for package.json
exportsmap (sub-path and wildcard entries) in thegenerate-apiexecutor, enabling packages like@fluentui/react-headless-components-previewto generate per-entry API reports and.d.tsrollups — fully automatically, without requiring additionalapi-extractorconfig files.NOTE: this is OPT IN by default
How to opt in
Configure
exportSubpathson thegenerate-apitarget inproject.json:{ "targets": { "generate-api": { "options": { "exportSubpaths": true } } } }NOTE: The workspace plugin reads this config and propagates it to the
buildtarget'sgenerateApioption 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-apiexecutorexportSubpathsoption (boolean | { apiReport?: boolean }) — when enabled, reads the package.jsonexportsmap and runs api-extractor for each resolved sub-path entry./*) into individual api-extractor runs per sub-directory./utils) into individual api-extractor runs.d.tsrollups (underdist/) and API reports (underetc/)api-extractor.*.jsonconfig files needed; the primary config'smainEntryPointFilePathis resolved and reused asdeclarationBaseresolveDeclarationBase,parseWildcardTypesPattern,parseNamedTypesPattern,listSubDirectories,createSubpathEntryConfig,resolveConfigSource)utils.tswithisWildcardTypedEntry/isNamedTypedEntryhelpersbuildexecutorgenerateApifrombooleantoboolean | { exportSubpaths?: boolean | { apiReport?: boolean } }— backward compatible with existingtrue/falseconfigsgenerateApiis an object, forward it asGenerateApiExecutorSchemato the generate-api executorWorkspace plugin
exportSubpathsfromgenerate-apitarget options inproject.jsongenerateApi: { exportSubpaths: <value> }to the build target so the build executor forwards it when calling generate-api internallydist/**/*.d.ts,etc/*.api.md) whenexportSubpathsis enabled