]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
workflow: ensure dev-sfc script build necessary deps if not present
authorEvan You <yyx990803@gmail.com>
Mon, 14 Nov 2022 02:14:12 +0000 (10:14 +0800)
committerEvan You <yyx990803@gmail.com>
Mon, 14 Nov 2022 02:14:12 +0000 (10:14 +0800)
package.json
scripts/pre-dev-sfc.js [new file with mode: 0644]

index 2a3cdae3517bc3070d57719a23a572d30808c1a2..0d539109890deb0f0db04f55d2f8408cbc73e241 100644 (file)
     "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
     "dev-esm": "node scripts/dev.js -if esm-bundler-runtime",
     "dev-compiler": "run-p \"dev template-explorer\" serve",
-    "dev-sfc": "run-p \"dev compiler-sfc -f esm-browser\" \"dev vue -if esm-bundler-runtime\" \"dev server-renderer -if esm-bundler\" serve-sfc-playground",
+    "dev-sfc-prepare": "node scripts/pre-dev-sfc.js || npm run build-compiler-cjs",
+    "dev-sfc-serve": "run-p \"dev compiler-sfc -f esm-browser\" \"dev vue -if esm-bundler-runtime\" \"dev server-renderer -if esm-bundler\" serve-sfc-playground",
+    "dev-sfc": "run-s \"dev-sfc-prepare\" \"dev-sfc-serve\"",
     "serve-sfc-playground": "vite packages/sfc-playground --host",
     "serve": "serve",
     "open": "open http://localhost:5000/packages/template-explorer/local.html",
-    "prebuild-sfc-playground": "node scripts/build.js compiler reactivity-transform shared -af cjs && node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime && node scripts/build.js compiler-sfc server-renderer -f esm-browser",
-    "build-sfc-playground": "cd packages/sfc-playground && npm run build",
+    "build-compiler-cjs": "node scripts/build.js compiler reactivity-transform shared -af cjs",
+    "build-runtime-esm": "node scripts/build.js runtime reactivity shared -af esm-bundler && node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js vue -f esm-browser-runtime",
+    "build-ssr-esm": "node scripts/build.js compiler-sfc server-renderer -f esm-browser",
+    "build-sfc-playground-self": "cd packages/sfc-playground && npm run build",
+    "build-sfc-playground": "run-s \"build-compiler-cjs\" \"build-runtime-esm\" \"build-ssr-esm\" \"build-sfc-playground-self\"",
     "preinstall": "node ./scripts/preinstall.js",
     "postinstall": "simple-git-hooks"
   },
diff --git a/scripts/pre-dev-sfc.js b/scripts/pre-dev-sfc.js
new file mode 100644 (file)
index 0000000..7ed54de
--- /dev/null
@@ -0,0 +1,28 @@
+const fs = require('fs')
+const path = require('path')
+
+const packagesToCheck = [
+  'compiler-sfc',
+  'compiler-core',
+  'compiler-dom',
+  'compiler-ssr',
+  'reactivity-transform',
+  'shared'
+]
+
+let allFilesPresent = true
+
+for (const pkg of packagesToCheck) {
+  if (
+    !fs.existsSync(
+      path.resolve(__dirname, `../packages/${pkg}/dist/${pkg}.cjs.js`)
+    )
+  ) {
+    allFilesPresent = false
+    break
+  }
+}
+
+if (!allFilesPresent) {
+  process.exit(1)
+}