(root: string, dtsPath: string, outputFile: string, externals: (string | RegExp)[])
| 25 | }; |
| 26 | |
| 27 | export default function generateDts(root: string, dtsPath: string, outputFile: string, externals: (string | RegExp)[]) { |
| 28 | exportAnalyzerExternals = externals; |
| 29 | |
| 30 | const extractorConfig: ExtractorConfig = ExtractorConfig.prepare({ |
| 31 | packageJsonFullPath: path.resolve(root, 'package.json'), |
| 32 | configObjectFullPath: undefined, |
| 33 | configObject: { |
| 34 | projectFolder: root, |
| 35 | mainEntryPointFilePath: dtsPath, |
| 36 | compiler: { |
| 37 | tsconfigFilePath: path.join(root, 'tsconfig.json') |
| 38 | }, |
| 39 | dtsRollup: { |
| 40 | enabled: true, |
| 41 | publicTrimmedFilePath: outputFile, |
| 42 | omitTrimmingComments: true |
| 43 | } |
| 44 | } |
| 45 | }); |
| 46 | |
| 47 | const typescriptPath = path.resolve(url.fileURLToPath(import.meta.resolve('typescript')), '..', '..'); |
| 48 | const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, { |
| 49 | localBuild: process.env.GITHUB_ACTIONS !== 'true', |
| 50 | typescriptCompilerFolder: typescriptPath |
| 51 | }); |
| 52 | |
| 53 | if (extractorResult.succeeded) { |
| 54 | console.log(`DTS bundled`, outputFile); |
| 55 | } else { |
| 56 | throw new Error( |
| 57 | `API Extractor completed with ${extractorResult.errorCount} errors` + |
| 58 | ` and ${extractorResult.warningCount} warnings` |
| 59 | ); |
| 60 | } |
| 61 | } |
no test coverage detected