Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions apps/api-extractor/src/api/ExtractorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { PackageMetadataManager } from '../analyzer/PackageMetadataManager';
import { MessageRouter } from '../collector/MessageRouter';
import type { IApiModelGenerationOptions } from '../generators/ApiModelGenerator';
import apiExtractorSchema from '../schemas/api-extractor.schema.json';
import apiExtractorDefaults from '../schemas/api-extractor-defaults.json';

/**
* Tokens used during variable expansion of path fields from api-extractor.json.
Expand Down Expand Up @@ -228,9 +229,9 @@ interface IExtractorConfigParameters {
enumMemberOrder: EnumMemberOrder;
}

const _defaultConfig: Partial<IConfigFile> = JsonFile.load(
path.join(__dirname, '../schemas/api-extractor-defaults.json')
);
// The defaults file deliberately omits fields that are required once a section is used
// (for example "apiReport.enabled"), so it does not structurally match IConfigFile.
const _defaultConfig: Partial<IConfigFile> = apiExtractorDefaults as unknown as Partial<IConfigFile>;

/**
* Match all three flavors for type declaration files (.d.ts, .d.mts, .d.cts)
Expand Down
5 changes: 0 additions & 5 deletions apps/api-extractor/src/schemas/api-extractor-defaults.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"projectFolder": "<lookup>",

// ("mainEntryPointFilePath" is required)

"bundledPackages": [],

"newlineKind": "crlf",
Expand All @@ -15,21 +13,18 @@
},

"apiReport": {
// ("enabled" is required)
"reportFileName": "<unscopedPackageName>.api.md",
"reportFolder": "<projectFolder>/etc/",
"reportTempFolder": "<projectFolder>/temp/",
"includeForgottenExports": false
},

"docModel": {
// ("enabled" is required)
"apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json",
"includeForgottenExports": false
},

"dtsRollup": {
// ("enabled" is required)
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
"alphaTrimmedFilePath": "",
"betaTrimmedFilePath": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"comment": "Fix an error that occurred when `@microsoft/api-extractor` was bundled into ESM output, caused by loading the default config from a `__dirname`-relative path at module initialization.",
"type": "patch",
"packageName": "@microsoft/api-extractor"
}
],
"packageName": "@microsoft/api-extractor"
}