build: use api-extractor for type rollup
This commit is contained in:
3
scripts/bootstrap.js
vendored
3
scripts/bootstrap.js
vendored
@@ -25,7 +25,8 @@ files.forEach(shortName => {
|
||||
description: name,
|
||||
main: 'index.js',
|
||||
module: `dist/${shortName}.esm-bundler.js`,
|
||||
types: 'dist/index.d.ts',
|
||||
files: [`index.js`, `dist`],
|
||||
types: `dist/${shortName}.d.ts`,
|
||||
repository: {
|
||||
type: 'git',
|
||||
url: 'git+https://github.com/vuejs/vue.git'
|
||||
|
||||
@@ -19,7 +19,6 @@ const path = require('path')
|
||||
const zlib = require('zlib')
|
||||
const chalk = require('chalk')
|
||||
const execa = require('execa')
|
||||
const dts = require('dts-bundle')
|
||||
const { targets, fuzzyMatchTarget } = require('./utils')
|
||||
|
||||
const args = require('minimist')(process.argv.slice(2))
|
||||
@@ -55,23 +54,42 @@ async function build(target) {
|
||||
'--environment',
|
||||
`NODE_ENV:production,` +
|
||||
`TARGET:${target}` +
|
||||
(formats ? `,FORMATS:${formats}` : ``)
|
||||
(formats ? `,FORMATS:${formats}` : ``) +
|
||||
(args.types ? `,TYPES:true` : ``)
|
||||
],
|
||||
{ stdio: 'inherit' }
|
||||
)
|
||||
|
||||
if (pkg.types) {
|
||||
const dtsOptions = {
|
||||
name: target === 'vue' ? target : `@vue/${target}`,
|
||||
main: `${pkgDir}/dist/packages/${target}/src/index.d.ts`,
|
||||
out: `${pkgDir}/${pkg.types}`
|
||||
}
|
||||
dts.bundle(dtsOptions)
|
||||
if (args.types && pkg.types) {
|
||||
console.log()
|
||||
console.log(
|
||||
chalk.blue(chalk.bold(`generated typings at ${dtsOptions.out}`))
|
||||
chalk.bold(chalk.yellow(`Rolling up type definitions for ${target}...`))
|
||||
)
|
||||
|
||||
// build types
|
||||
const { Extractor, ExtractorConfig } = require('@microsoft/api-extractor')
|
||||
|
||||
const extractorConfigPath = path.resolve(pkgDir, `api-extractor.json`)
|
||||
const extractorConfig = ExtractorConfig.loadFileAndPrepare(
|
||||
extractorConfigPath
|
||||
)
|
||||
const result = Extractor.invoke(extractorConfig, {
|
||||
localBuild: true,
|
||||
showVerboseMessages: true
|
||||
})
|
||||
|
||||
if (result.succeeded) {
|
||||
console.log(
|
||||
chalk.bold(chalk.green(`API Extractor completed successfully.`))
|
||||
)
|
||||
} else {
|
||||
console.error(
|
||||
`API Extractor completed with ${extractorResult.errorCount} errors` +
|
||||
` and ${extractorResult.warningCount} warnings`
|
||||
)
|
||||
process.exitCode = 1
|
||||
}
|
||||
|
||||
await fs.remove(`${pkgDir}/dist/packages`)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user