mirror of https://github.com/vuejs/core.git
workflow: support building types in build script
This commit is contained in:
parent
57f0fbe76a
commit
7f1b546a99
|
@ -12,7 +12,13 @@ if (!existsSync('temp/packages')) {
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default readdirSync('temp/packages').map(pkg => {
|
const packages = readdirSync('temp/packages')
|
||||||
|
const targets = process.env.TARGETS ? process.env.TARGETS.split(',') : null
|
||||||
|
const targetPackages = targets
|
||||||
|
? packages.filter(pkg => targets.includes(pkg))
|
||||||
|
: packages
|
||||||
|
|
||||||
|
export default targetPackages.map(pkg => {
|
||||||
return {
|
return {
|
||||||
input: `./temp/packages/${pkg}/src/index.d.ts`,
|
input: `./temp/packages/${pkg}/src/index.d.ts`,
|
||||||
output: {
|
output: {
|
||||||
|
|
|
@ -34,6 +34,7 @@ const targets = args._
|
||||||
const formats = args.formats || args.f
|
const formats = args.formats || args.f
|
||||||
const devOnly = args.devOnly || args.d
|
const devOnly = args.devOnly || args.d
|
||||||
const prodOnly = !devOnly && (args.prodOnly || args.p)
|
const prodOnly = !devOnly && (args.prodOnly || args.p)
|
||||||
|
const buildTypes = args.withTypes || args.t
|
||||||
const sourceMap = args.sourcemap || args.s
|
const sourceMap = args.sourcemap || args.s
|
||||||
const isRelease = args.release
|
const isRelease = args.release
|
||||||
const buildAllMatching = args.all || args.a
|
const buildAllMatching = args.all || args.a
|
||||||
|
@ -44,12 +45,25 @@ run()
|
||||||
async function run() {
|
async function run() {
|
||||||
const removeCache = scanEnums()
|
const removeCache = scanEnums()
|
||||||
try {
|
try {
|
||||||
if (!targets.length) {
|
const resolvedTargets = targets.length
|
||||||
await buildAll(allTargets)
|
? fuzzyMatchTarget(targets, buildAllMatching)
|
||||||
checkAllSizes(allTargets)
|
: allTargets
|
||||||
} else {
|
await buildAll(resolvedTargets)
|
||||||
await buildAll(fuzzyMatchTarget(targets, buildAllMatching))
|
checkAllSizes(resolvedTargets)
|
||||||
checkAllSizes(fuzzyMatchTarget(targets, buildAllMatching))
|
if (buildTypes) {
|
||||||
|
await execa(
|
||||||
|
'pnpm',
|
||||||
|
[
|
||||||
|
'run',
|
||||||
|
'build-dts',
|
||||||
|
...(targets.length
|
||||||
|
? ['--environment', `TARGETS:${resolvedTargets.join(',')}`]
|
||||||
|
: [])
|
||||||
|
],
|
||||||
|
{
|
||||||
|
stdio: 'inherit'
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
removeCache()
|
removeCache()
|
||||||
|
|
|
@ -199,9 +199,9 @@ async function main() {
|
||||||
// build all packages with types
|
// build all packages with types
|
||||||
step('\nBuilding all packages...')
|
step('\nBuilding all packages...')
|
||||||
if (!skipBuild && !isDryRun) {
|
if (!skipBuild && !isDryRun) {
|
||||||
await run('pnpm', ['run', 'build'])
|
await run('pnpm', ['run', 'build', '--withTypes'])
|
||||||
step('\nBuilding and testing types...')
|
step('\nTesting built types...')
|
||||||
await run('pnpm', ['test-dts'])
|
await run('pnpm', ['test-dts-only'])
|
||||||
} else {
|
} else {
|
||||||
console.log(`(skipped)`)
|
console.log(`(skipped)`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue