]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: improve build script to only build package when format is valid
authorEvan You <evan@vuejs.org>
Sat, 8 Feb 2025 09:35:52 +0000 (17:35 +0800)
committerEvan You <evan@vuejs.org>
Sat, 8 Feb 2025 09:35:52 +0000 (17:35 +0800)
scripts/build.js

index 7af93db4043203f4aebbb81be98794c49625606f..01d1cba52e4340da79112a2a5fd0aab721a226ca 100644 (file)
@@ -173,6 +173,17 @@ async function build(target) {
     return
   }
 
+  if (formats) {
+    let resolvedFormats = formats.split('+')
+    const pkgFormats = pkg.buildOptions?.formats
+    if (pkgFormats) {
+      resolvedFormats = resolvedFormats.filter(f => pkgFormats.includes(f))
+    }
+    if (!resolvedFormats.length) {
+      return
+    }
+  }
+
   // if building a specific format, do not remove dist.
   if (!formats && existsSync(`${pkgDir}/dist`)) {
     fs.rmSync(`${pkgDir}/dist`, { recursive: true })