Skip to content

Commit 7f1b546

Browse files
committed
workflow: support building types in build script
1 parent 57f0fbe commit 7f1b546

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

rollup.dts.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ if (!existsSync('temp/packages')) {
1212
process.exit(1)
1313
}
1414

15-
export default readdirSync('temp/packages').map(pkg => {
15+
const packages = readdirSync('temp/packages')
16+
const targets = process.env.TARGETS ? process.env.TARGETS.split(',') : null
17+
const targetPackages = targets
18+
? packages.filter(pkg => targets.includes(pkg))
19+
: packages
20+
21+
export default targetPackages.map(pkg => {
1622
return {
1723
input: `./temp/packages/${pkg}/src/index.d.ts`,
1824
output: {

scripts/build.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const targets = args._
3434
const formats = args.formats || args.f
3535
const devOnly = args.devOnly || args.d
3636
const prodOnly = !devOnly && (args.prodOnly || args.p)
37+
const buildTypes = args.withTypes || args.t
3738
const sourceMap = args.sourcemap || args.s
3839
const isRelease = args.release
3940
const buildAllMatching = args.all || args.a
@@ -44,12 +45,25 @@ run()
4445
async function run() {
4546
const removeCache = scanEnums()
4647
try {
47-
if (!targets.length) {
48-
await buildAll(allTargets)
49-
checkAllSizes(allTargets)
50-
} else {
51-
await buildAll(fuzzyMatchTarget(targets, buildAllMatching))
52-
checkAllSizes(fuzzyMatchTarget(targets, buildAllMatching))
48+
const resolvedTargets = targets.length
49+
? fuzzyMatchTarget(targets, buildAllMatching)
50+
: allTargets
51+
await buildAll(resolvedTargets)
52+
checkAllSizes(resolvedTargets)
53+
if (buildTypes) {
54+
await execa(
55+
'pnpm',
56+
[
57+
'run',
58+
'build-dts',
59+
...(targets.length
60+
? ['--environment', `TARGETS:${resolvedTargets.join(',')}`]
61+
: [])
62+
],
63+
{
64+
stdio: 'inherit'
65+
}
66+
)
5367
}
5468
} finally {
5569
removeCache()

scripts/release.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ async function main() {
199199
// build all packages with types
200200
step('\nBuilding all packages...')
201201
if (!skipBuild && !isDryRun) {
202-
await run('pnpm', ['run', 'build'])
203-
step('\nBuilding and testing types...')
204-
await run('pnpm', ['test-dts'])
202+
await run('pnpm', ['run', 'build', '--withTypes'])
203+
step('\nTesting built types...')
204+
await run('pnpm', ['test-dts-only'])
205205
} else {
206206
console.log(`(skipped)`)
207207
}

0 commit comments

Comments
 (0)