X Tutup
Skip to content

Commit fd8ff36

Browse files
committed
Implement tsconfigFilePath
1 parent 9ba1d36 commit fd8ff36

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

apps/api-extractor/src/api/CompilerState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class CompilerState {
5252
let tsconfig: {} | undefined = extractorConfig.overrideTsconfig;
5353
if (!tsconfig) {
5454
// If it wasn't overridden, then load it from disk
55-
tsconfig = JsonFile.load(path.join(extractorConfig.projectFolder, 'tsconfig.json'));
55+
tsconfig = JsonFile.load(extractorConfig.tsconfigFilePath);
5656
}
5757

5858
const commandLine: ts.ParsedCommandLine = ts.parseJsonConfigFileContent(

apps/api-extractor/src/api/ExtractorConfig.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ interface IExtractorConfigParameters {
9494
packageJson: INodePackageJson | undefined;
9595
packageJsonFullPath: string | undefined;
9696
mainEntryPointFile: string;
97+
tsconfigFilePath: string;
9798
overrideTsconfig: { } | undefined;
9899
skipLibCheck: boolean;
99100
apiReportEnabled: boolean;
@@ -150,6 +151,9 @@ export class ExtractorConfig {
150151
/** {@inheritDoc IConfigFile.mainEntryPointFile} */
151152
public readonly mainEntryPointFile: string;
152153

154+
/** {@inheritDoc IConfigCompiler.tsconfigFilePath} */
155+
public readonly tsconfigFilePath: string;
156+
153157
/** {@inheritDoc IConfigCompiler.overrideTsconfig} */
154158
public readonly overrideTsconfig: { } | undefined;
155159

@@ -194,6 +198,7 @@ export class ExtractorConfig {
194198
this.packageJson = parameters.packageJson;
195199
this.packageJsonFullPath = parameters.packageJsonFullPath;
196200
this.mainEntryPointFile = parameters.mainEntryPointFile;
201+
this.tsconfigFilePath = parameters.tsconfigFilePath;
197202
this.overrideTsconfig = parameters.overrideTsconfig;
198203
this.skipLibCheck = parameters.skipLibCheck;
199204
this.apiReportEnabled = parameters.apiReportEnabled;
@@ -342,6 +347,13 @@ export class ExtractorConfig {
342347
'mainEntryPointFile', configFile.mainEntryPointFile, currentConfigFolderPath);
343348
}
344349

350+
if (configFile.compiler) {
351+
if (configFile.compiler.tsconfigFilePath) {
352+
configFile.compiler.tsconfigFilePath = ExtractorConfig._resolveConfigFileRelativePath(
353+
'tsconfigFilePath', configFile.compiler.tsconfigFilePath, currentConfigFolderPath);
354+
}
355+
}
356+
345357
if (configFile.apiReport) {
346358
if (configFile.apiReport.reportFolder) {
347359
configFile.apiReport.reportFolder = ExtractorConfig._resolveConfigFileRelativePath(
@@ -494,17 +506,29 @@ export class ExtractorConfig {
494506

495507
if (!configObject.mainEntryPointFile) {
496508
// A merged configuration should have this
497-
throw new Error('mainEntryPointFile is missing');
509+
throw new Error('The "mainEntryPointFile" setting is missing');
498510
}
499511
const mainEntryPointFile: string = ExtractorConfig._resolvePathWithTokens('mainEntryPointFile',
500512
configObject.mainEntryPointFile, tokenContext);
501513

502514
if (!ExtractorConfig.hasDtsFileExtension(mainEntryPointFile)) {
503-
throw new Error('The mainEntryPointFile is not a declaration file: ' + mainEntryPointFile);
515+
throw new Error('The "mainEntryPointFile" is not a declaration file: ' + mainEntryPointFile);
504516
}
505517

506518
if (!FileSystem.exists(mainEntryPointFile)) {
507-
throw new Error('The mainEntryPointFile does not exist: ' + mainEntryPointFile);
519+
throw new Error('The "mainEntryPointFile" does not exist: ' + mainEntryPointFile);
520+
}
521+
522+
const tsconfigFilePath: string = ExtractorConfig._resolvePathWithTokens('tsconfigFilePath',
523+
configObject.compiler.tsconfigFilePath, tokenContext);
524+
525+
if (configObject.compiler.overrideTsconfig === undefined) {
526+
if (!configObject.compiler.tsconfigFilePath) {
527+
throw new Error('Either the "tsconfigFilePath" or "overrideTsconfig" setting must be specified');
528+
}
529+
if (!FileSystem.exists(configObject.compiler.tsconfigFilePath)) {
530+
throw new Error('The "tsconfigFilePath" does not exist: ' + configObject.compiler.tsconfigFilePath);
531+
}
508532
}
509533

510534
let apiReportEnabled: boolean = false;
@@ -594,6 +618,7 @@ export class ExtractorConfig {
594618
packageJson,
595619
packageJsonFullPath,
596620
mainEntryPointFile,
621+
tsconfigFilePath,
597622
overrideTsconfig: configObject.compiler.overrideTsconfig,
598623
skipLibCheck: !!configObject.compiler.skipLibCheck,
599624
apiReportEnabled,

common/reviews/api/api-extractor.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class ExtractorConfig {
6161
readonly rollupEnabled: boolean;
6262
readonly skipLibCheck: boolean;
6363
readonly testMode: boolean;
64+
readonly tsconfigFilePath: string;
6465
readonly tsdocMetadataEnabled: boolean;
6566
readonly tsdocMetadataFilePath: string;
6667
readonly untrimmedFilePath: string;
@@ -150,6 +151,7 @@ export interface IConfigApiReport {
150151
export interface IConfigCompiler {
151152
overrideTsconfig?: {};
152153
skipLibCheck?: boolean;
154+
tsconfigFilePath?: string;
153155
}
154156

155157
// @public

0 commit comments

Comments
 (0)
X Tutup