From 30583b9ee1c696d3cb836f0bfd969793e57e849d Mon Sep 17 00:00:00 2001 From: Rizumu Ayaka Date: Mon, 19 Aug 2024 17:30:52 +0800 Subject: [PATCH] workflow: add dev build mode for benchmark --- benchmark/index.js | 28 ++++++++++++++++++---------- benchmark/package.json | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index 2d4eedf64..322c58af9 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -21,6 +21,7 @@ const { port: portStr, count: countStr, noHeadless, + devBuild, }, } = parseArgs({ allowNegative: true, @@ -58,6 +59,10 @@ const { noHeadless: { type: 'boolean', }, + devBuild: { + type: 'boolean', + short: 'd', + }, }, }) @@ -87,10 +92,11 @@ async function buildLib() { cwd: path.resolve(import.meta.dirname, '..'), stdio: 'inherit', } + const BuildOptions = devBuild ? '-df' : '-pf' const [{ ok }, { ok: ok2 }, { ok: ok3 }, { ok: ok4 }] = await Promise.all([ exec( 'pnpm', - 'run --silent build shared compiler-core compiler-dom compiler-vapor -pf cjs'.split( + `run --silent build shared compiler-core compiler-dom compiler-vapor ${BuildOptions} cjs`.split( ' ', ), options, @@ -102,12 +108,12 @@ async function buildLib() { ), exec( 'pnpm', - 'run --silent build vue-vapor -pf esm-browser'.split(' '), + `run --silent build vue-vapor ${BuildOptions} esm-browser`.split(' '), options, ), exec( 'pnpm', - 'run --silent build vue -pf esm-browser-runtime'.split(' '), + `run --silent build vue ${BuildOptions} esm-browser-runtime`.split(' '), options, ), ]) @@ -128,17 +134,19 @@ async function buildApp(isVapor) { const CompilerSFC = await import( '../packages/compiler-sfc/dist/compiler-sfc.cjs.js' ) + const prodSuffix = devBuild ? '.js' : '.prod.js' + /** @type {any} */ const TemplateCompiler = await import( - isVapor - ? '../packages/compiler-vapor/dist/compiler-vapor.cjs.prod.js' - : '../packages/compiler-dom/dist/compiler-dom.cjs.prod.js' + (isVapor + ? '../packages/compiler-vapor/dist/compiler-vapor.cjs' + : '../packages/compiler-dom/dist/compiler-dom.cjs') + prodSuffix ) const runtimePath = path.resolve( import.meta.dirname, - isVapor - ? '../packages/vue-vapor/dist/vue-vapor.esm-browser.prod.js' - : '../packages/vue/dist/vue.runtime.esm-browser.prod.js', + (isVapor + ? '../packages/vue-vapor/dist/vue-vapor.esm-browser' + : '../packages/vue/dist/vue.runtime.esm-browser') + prodSuffix, ) const mode = isVapor ? 'vapor' : 'vdom' @@ -149,7 +157,7 @@ async function buildApp(isVapor) { 'import.meta.env.IS_VAPOR': String(isVapor), }, build: { - minify: 'terser', + minify: !devBuild && 'terser', outDir: path.resolve('./client/dist', mode), rollupOptions: { onwarn(log, handler) { diff --git a/benchmark/package.json b/benchmark/package.json index 091db7a40..dcd215680 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -5,7 +5,7 @@ "license": "MIT", "type": "module", "scripts": { - "dev": "pnpm start --noHeadless --skipBench --vdom", + "dev": "pnpm start --devBuild --noHeadless --skipBench --vdom", "start": "node index.js" }, "dependencies": {