From d669e75d95439364b5fbe2550e06de9fafd1c96a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 14 Jul 2021 13:59:08 +0200 Subject: [PATCH] scripts/api-extractor: enable warnings in API reports Signed-off-by: Patrik Oldsberg --- scripts/api-extractor.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index f88b30d1fd..21c61599a4 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -150,16 +150,11 @@ async function runApiExtraction({ for (const packageDir of packageDirs) { console.log(`## Processing ${packageDir}`); const projectFolder = resolvePath(__dirname, '..', packageDir); - const packagePath = resolvePath(__dirname, `../${packageDir}/package.json`); + const packageFolder = resolvePath(__dirname, '../dist-types', packageDir); const extractorConfig = ExtractorConfig.prepare({ configObject: { - mainEntryPointFilePath: resolvePath( - __dirname, - '../dist-types', - packageDir, - 'src/index.d.ts', - ), + mainEntryPointFilePath: resolvePath(packageFolder, 'src/index.d.ts'), bundledPackages: [], compiler: { @@ -190,7 +185,7 @@ async function runApiExtraction({ }, messages: { - // Silence warnings, as these will prevent the CI build to work + // Silence compiler warnings, as these will prevent the CI build to work compilerMessageReporting: { default: { logLevel: 'none' as ExtractorLogLevel.None, @@ -200,14 +195,14 @@ async function runApiExtraction({ }, extractorMessageReporting: { default: { - logLevel: 'none' as ExtractorLogLevel.Warning, - // addToApiReportFile: true, + logLevel: 'warning' as ExtractorLogLevel.Warning, + addToApiReportFile: true, }, }, tsdocMessageReporting: { default: { - logLevel: 'none' as ExtractorLogLevel.Warning, - // addToApiReportFile: true, + logLevel: 'warning' as ExtractorLogLevel.Warning, + addToApiReportFile: true, }, }, }, @@ -217,9 +212,16 @@ async function runApiExtraction({ projectFolder, }, configObjectFullPath: projectFolder, - packageJsonFullPath: packagePath, + packageJsonFullPath: resolvePath(projectFolder, 'package.json'), }); + // The `packageFolder` needs to point to the location within `dist-types` in order for relative + // paths to be logged. Unfortunately the `prepare` method above derives it from the `packageJsonFullPath`, + // which needs to point to the actual file, so we override `packageFolder` afterwards. + (extractorConfig as { + packageFolder: string; + }).packageFolder = packageFolder; + if (!compilerState) { compilerState = CompilerState.create(extractorConfig, { additionalEntryPoints: entryPoints,