Skip to content

Commit 88b9d10

Browse files
committed
PR feedback
1 parent 059deab commit 88b9d10

3 files changed

Lines changed: 26 additions & 24 deletions

File tree

‎apps/api-extractor/src/extractor/Extractor.ts‎

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,18 @@ export class Extractor {
345345
}
346346
}
347347

348+
this._generateRollupDtsFiles(context);
349+
350+
if (this._localBuild) {
351+
// For a local build, fail if there were errors (but ignore warnings)
352+
return this._monitoredLogger.errorCount === 0;
353+
} else {
354+
// For a production build, fail if there were any errors or warnings
355+
return (this._monitoredLogger.errorCount + this._monitoredLogger.warningCount) === 0;
356+
}
357+
}
358+
359+
private _generateRollupDtsFiles(context: ExtractorContext): void {
348360
const dtsRollup: IExtractorDtsRollupConfig = this.actualConfig.dtsRollup!;
349361
if (dtsRollup.enabled) {
350362
let mainDtsRollupPath: string = dtsRollup.mainDtsRollupPath!;
@@ -354,27 +366,26 @@ export class Extractor {
354366
if (!context.packageJson.typings) {
355367
this._monitoredLogger.logError('Either the "mainDtsRollupPath" setting must be specified,'
356368
+ ' or else the package.json file must contain a "typings" field.');
357-
return false;
369+
return;
358370
}
359371

360372
// Resolve the "typings" field relative to package.json itself
361-
const resolvedTypings: string = path.resolve(context.packageFolder,
362-
context.packageJson.typings);
373+
const resolvedTypings: string = path.resolve(context.packageFolder, context.packageJson.typings);
363374

364375
if (dtsRollup.trimming) {
365376
if (!Path.isUnder(resolvedTypings, dtsRollup.publishFolderForInternal!)) {
366377
this._monitoredLogger.logError('The "mainDtsRollupPath" setting was not specified.'
367378
+ ' In this case, the package.json "typings" field must point to a file under'
368379
+ ' the "publishFolderForInternal": ' + dtsRollup.publishFolderForInternal!);
369-
return false;
380+
return;
370381
}
371382
mainDtsRollupPath = path.relative(dtsRollup.publishFolderForInternal!, resolvedTypings);
372383
} else {
373384
if (!Path.isUnder(resolvedTypings, dtsRollup.publishFolder!)) {
374385
this._monitoredLogger.logError('The "mainDtsRollupPath" setting was not specified.'
375386
+ ' In this case, the package.json "typings" field must point to a file under'
376387
+ ' the "publishFolder": ' + dtsRollup.publishFolder!);
377-
return false;
388+
return;
378389
}
379390
mainDtsRollupPath = path.relative(dtsRollup.publishFolder!, resolvedTypings);
380391
}
@@ -386,44 +397,35 @@ export class Extractor {
386397

387398
if (!path.isAbsolute(mainDtsRollupPath)) {
388399
this._monitoredLogger.logError('The "mainDtsRollupPath" setting must be a relative path'
389-
+ ' that can be combined with "publishFolderForInternal", "publishFolderForBeta", '
390-
+ 'or "publishFolderForPublic".');
391-
return false;
400+
+ ' that can be combined with one of the "publishFolder" settings.');
401+
return;
392402
}
393403
}
394404

395405
const dtsRollupGenerator: DtsRollupGenerator = new DtsRollupGenerator(context);
396406
dtsRollupGenerator.analyze();
397407

398408
if (dtsRollup.trimming) {
399-
this._generateTypingsFile(dtsRollupGenerator,
409+
this._generateRollupDtsFile(dtsRollupGenerator,
400410
path.resolve(context.packageFolder, dtsRollup.publishFolderForPublic!, mainDtsRollupPath),
401411
DtsRollupKind.PublicRelease);
402412

403-
this._generateTypingsFile(dtsRollupGenerator,
413+
this._generateRollupDtsFile(dtsRollupGenerator,
404414
path.resolve(context.packageFolder, dtsRollup.publishFolderForBeta!, mainDtsRollupPath),
405415
DtsRollupKind.BetaRelease);
406416

407-
this._generateTypingsFile(dtsRollupGenerator,
417+
this._generateRollupDtsFile(dtsRollupGenerator,
408418
path.resolve(context.packageFolder, dtsRollup.publishFolderForInternal!, mainDtsRollupPath),
409419
DtsRollupKind.InternalRelease);
410420
} else {
411-
this._generateTypingsFile(dtsRollupGenerator,
421+
this._generateRollupDtsFile(dtsRollupGenerator,
412422
path.resolve(context.packageFolder, dtsRollup.publishFolder!, mainDtsRollupPath),
413423
DtsRollupKind.InternalRelease); // (no trimming)
414424
}
415425
}
416-
417-
if (this._localBuild) {
418-
// For a local build, fail if there were errors (but ignore warnings)
419-
return this._monitoredLogger.errorCount === 0;
420-
} else {
421-
// For a production build, fail if there were any errors or warnings
422-
return (this._monitoredLogger.errorCount + this._monitoredLogger.warningCount) === 0;
423-
}
424426
}
425427

426-
private _generateTypingsFile(dtsRollupGenerator: DtsRollupGenerator, mainDtsRollupFullPath: string,
428+
private _generateRollupDtsFile(dtsRollupGenerator: DtsRollupGenerator, mainDtsRollupFullPath: string,
427429
dtsKind: DtsRollupKind): void {
428430

429431
this._monitoredLogger.logVerbose(`Writing package typings: ${mainDtsRollupFullPath}`);

‎apps/api-extractor/src/extractor/IExtractorConfig.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ export interface IExtractorApiJsonFileConfig {
181181
* Configures how the *.d.ts rollup files will be generated.
182182
*
183183
* @remarks
184-
* API Extractor can generate a single unified *.d.ts file that contains all
184+
* API Extractor can generate a consolidated *.d.ts file that contains all
185185
* the exported typings for the package entry point. It can also trim
186186
* \@alpha, \@beta, and \@internal definitions according to the release type.
187187
*
188188
* @beta
189189
*/
190190
export interface IExtractorDtsRollupConfig {
191191
/**
192-
* Whether to generate package typings. The default is false.
192+
* Whether to generate rollup *.d.ts files. The default is false.
193193
*/
194194
enabled: boolean;
195195

‎apps/api-extractor/src/extractor/api-extractor.schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"type": "object",
134134
"properties": {
135135
"enabled": {
136-
"description": "Whether to generate package typings. The default is false.",
136+
"description": "Whether to generate rollup *.d.ts files. The default is false.",
137137
"type": "boolean"
138138
},
139139
"trimming": {

0 commit comments

Comments
 (0)