]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
workflow: support building types in build script
authorEvan You <yyx990803@gmail.com>
Tue, 18 Apr 2023 03:39:21 +0000 (11:39 +0800)
committerEvan You <yyx990803@gmail.com>
Tue, 18 Apr 2023 03:39:21 +0000 (11:39 +0800)
rollup.dts.config.js
scripts/build.js
scripts/release.js

index 1b4df21adaccf7886ef34552a09b333b030ad264..bb146c46279c5a72e4cc38f4a9f27fe300f7c5a2 100644 (file)
@@ -12,7 +12,13 @@ if (!existsSync('temp/packages')) {
   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 {
     input: `./temp/packages/${pkg}/src/index.d.ts`,
     output: {
index 05ed32ebc5c9c71d4b8e92ddf552ca236f7b28f0..689d3dc9351e72ca3d6d75f48bcc532bac037fac 100644 (file)
@@ -34,6 +34,7 @@ const targets = args._
 const formats = args.formats || args.f
 const devOnly = args.devOnly || args.d
 const prodOnly = !devOnly && (args.prodOnly || args.p)
+const buildTypes = args.withTypes || args.t
 const sourceMap = args.sourcemap || args.s
 const isRelease = args.release
 const buildAllMatching = args.all || args.a
@@ -44,12 +45,25 @@ run()
 async function run() {
   const removeCache = scanEnums()
   try {
-    if (!targets.length) {
-      await buildAll(allTargets)
-      checkAllSizes(allTargets)
-    } else {
-      await buildAll(fuzzyMatchTarget(targets, buildAllMatching))
-      checkAllSizes(fuzzyMatchTarget(targets, buildAllMatching))
+    const resolvedTargets = targets.length
+      ? fuzzyMatchTarget(targets, buildAllMatching)
+      : allTargets
+    await buildAll(resolvedTargets)
+    checkAllSizes(resolvedTargets)
+    if (buildTypes) {
+      await execa(
+        'pnpm',
+        [
+          'run',
+          'build-dts',
+          ...(targets.length
+            ? ['--environment', `TARGETS:${resolvedTargets.join(',')}`]
+            : [])
+        ],
+        {
+          stdio: 'inherit'
+        }
+      )
     }
   } finally {
     removeCache()
index 15130174149736eeb74b41ae6659a18c2a0bba12..4eabe911bee819eb5f3d32ac40ac7d9b1e9fbaf0 100644 (file)
@@ -199,9 +199,9 @@ async function main() {
   // build all packages with types
   step('\nBuilding all packages...')
   if (!skipBuild && !isDryRun) {
-    await run('pnpm', ['run', 'build'])
-    step('\nBuilding and testing types...')
-    await run('pnpm', ['test-dts'])
+    await run('pnpm', ['run', 'build', '--withTypes'])
+    step('\nTesting built types...')
+    await run('pnpm', ['test-dts-only'])
   } else {
     console.log(`(skipped)`)
   }