Skip to content

Commit

Permalink
workflow: add dev build mode for benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSound committed Aug 19, 2024
1 parent abd685d commit 30583b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
port: portStr,
count: countStr,
noHeadless,
devBuild,
},
} = parseArgs({
allowNegative: true,
Expand Down Expand Up @@ -58,6 +59,10 @@ const {
noHeadless: {
type: 'boolean',
},
devBuild: {
type: 'boolean',
short: 'd',
},
},
})

Expand Down Expand Up @@ -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,
Expand All @@ -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,
),
])
Expand All @@ -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'
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 30583b9

Please sign in to comment.