From 9058ad7a0c91c3bebe8af66beb021a0f847d4a89 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 18 May 2026 16:20:14 +0900 Subject: [PATCH 1/6] test: benchmark smoke test --- .../benchmark-utils/package.json | 1 + .../benchmark-utils/src/run-build.ts | 33 +++++++++++++++++++ .../emotion/benchmark/bench/emotion.bench.ts | 14 +++----- .../emotion/benchmark/bench/emotion.test.ts | 21 ++++++++++++ .../bench/jsx-remove-attributes.bench.ts | 14 +++----- .../bench/jsx-remove-attributes.test.ts | 21 ++++++++++++ .../benchmark/bench/styled-jsx.bench.ts | 14 +++----- .../benchmark/bench/styled-jsx.test.ts | 21 ++++++++++++ .../bench/transform-imports.bench.ts | 14 +++----- .../benchmark/bench/transform-imports.test.ts | 21 ++++++++++++ 10 files changed, 134 insertions(+), 40 deletions(-) create mode 100644 internal-packages/benchmark-utils/src/run-build.ts create mode 100644 packages/emotion/benchmark/bench/emotion.test.ts create mode 100644 packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts create mode 100644 packages/styled-jsx/benchmark/bench/styled-jsx.test.ts create mode 100644 packages/transform-imports/benchmark/bench/transform-imports.test.ts diff --git a/internal-packages/benchmark-utils/package.json b/internal-packages/benchmark-utils/package.json index d2b8e62..7922767 100644 --- a/internal-packages/benchmark-utils/package.json +++ b/internal-packages/benchmark-utils/package.json @@ -4,6 +4,7 @@ "private": true, "type": "module", "exports": { + "./run-build": "./src/run-build.ts", "./seeded-random": "./src/seeded-random.ts" }, "devDependencies": { diff --git a/internal-packages/benchmark-utils/src/run-build.ts b/internal-packages/benchmark-utils/src/run-build.ts new file mode 100644 index 0000000..39f315d --- /dev/null +++ b/internal-packages/benchmark-utils/src/run-build.ts @@ -0,0 +1,33 @@ +import { execSync } from 'node:child_process' +import { Buffer } from 'node:buffer' + +function asString(value: unknown): string { + if (typeof value === 'string') return value + if (Buffer.isBuffer(value)) return value.toString('utf8') + return '' +} + +export function runBuild(configName: string, baseDir: string): void { + try { + execSync(`rolldown -c configs/${configName}.ts`, { + cwd: baseDir, + stdio: 'pipe', + }) + } catch (err) { + const isObject = typeof err === 'object' && err !== null + const status = + isObject && 'status' in err && typeof err.status === 'number' + ? err.status + : null + const stdout = asString( + isObject && 'stdout' in err ? err.stdout : undefined, + ) + const stderr = asString( + isObject && 'stderr' in err ? err.stderr : undefined, + ) + throw new Error( + `build:${configName} failed (exit ${status ?? 'unknown'}):\n${stdout}${stderr}`, + { cause: err }, + ) + } +} diff --git a/packages/emotion/benchmark/bench/emotion.bench.ts b/packages/emotion/benchmark/bench/emotion.bench.ts index 373d192..d30b9e5 100644 --- a/packages/emotion/benchmark/bench/emotion.bench.ts +++ b/packages/emotion/benchmark/bench/emotion.bench.ts @@ -2,6 +2,7 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' import { existsSync, rmSync } from 'node:fs' import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') @@ -18,18 +19,11 @@ function cleanDist(name: string) { } } -function runBuild(name: string) { - execSync(`rolldown -c configs/${name}.ts`, { - cwd: baseDir, - stdio: 'pipe', - }) -} - describe('Emotion Benchmark', () => { bench( '@rolldown/plugin-emotion', () => { - runBuild('custom') + runBuild('custom', baseDir) }, { teardown: () => cleanDist('custom') }, ) @@ -37,7 +31,7 @@ describe('Emotion Benchmark', () => { bench( '@rolldown/plugin-babel', () => { - runBuild('babel') + runBuild('babel', baseDir) }, { teardown: () => cleanDist('babel') }, ) @@ -45,7 +39,7 @@ describe('Emotion Benchmark', () => { bench( '@rollup/plugin-swc', () => { - runBuild('swc') + runBuild('swc', baseDir) }, { teardown: () => cleanDist('swc') }, ) diff --git a/packages/emotion/benchmark/bench/emotion.test.ts b/packages/emotion/benchmark/bench/emotion.test.ts new file mode 100644 index 0000000..828c89a --- /dev/null +++ b/packages/emotion/benchmark/bench/emotion.test.ts @@ -0,0 +1,21 @@ +import { describe, test } from 'vitest' +import { execSync } from 'node:child_process' +import { existsSync } from 'node:fs' +import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' + +const baseDir = resolve(import.meta.dirname, '..') +const componentsDir = resolve(baseDir, 'shared-app/src/components') + +if (!existsSync(componentsDir)) { + execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) +} + +describe('Emotion build', () => { + test.for(['custom', 'babel', 'swc'] as const)( + 'build:%s exits with code 0', + (name) => { + runBuild(name, baseDir) + }, + ) +}) diff --git a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts index f193c5e..c1df018 100644 --- a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts +++ b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts @@ -2,6 +2,7 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' import { existsSync, rmSync } from 'node:fs' import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') @@ -18,18 +19,11 @@ function cleanDist(name: string) { } } -function runBuild(name: string) { - execSync(`rolldown -c configs/${name}.ts`, { - cwd: baseDir, - stdio: 'pipe', - }) -} - describe('JSX Remove Attributes Benchmark', () => { bench( '@rolldown/plugin-jsx-remove-attributes', () => { - runBuild('custom') + runBuild('custom', baseDir) }, { teardown: () => cleanDist('custom') }, ) @@ -37,7 +31,7 @@ describe('JSX Remove Attributes Benchmark', () => { bench( '@rolldown/plugin-babel', () => { - runBuild('babel') + runBuild('babel', baseDir) }, { teardown: () => cleanDist('babel') }, ) @@ -45,7 +39,7 @@ describe('JSX Remove Attributes Benchmark', () => { bench( '@rollup/plugin-swc', () => { - runBuild('swc') + runBuild('swc', baseDir) }, { teardown: () => cleanDist('swc') }, ) diff --git a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts new file mode 100644 index 0000000..597f221 --- /dev/null +++ b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts @@ -0,0 +1,21 @@ +import { describe, test } from 'vitest' +import { execSync } from 'node:child_process' +import { existsSync } from 'node:fs' +import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' + +const baseDir = resolve(import.meta.dirname, '..') +const componentsDir = resolve(baseDir, 'shared-app/src/components') + +if (!existsSync(componentsDir)) { + execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) +} + +describe('JSX Remove Attributes build', () => { + test.for(['custom', 'babel', 'swc'] as const)( + 'build:%s exits with code 0', + (name) => { + runBuild(name, baseDir) + }, + ) +}) diff --git a/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts b/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts index 44f8458..df4214b 100644 --- a/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts +++ b/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts @@ -2,6 +2,7 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' import { existsSync, rmSync } from 'node:fs' import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') @@ -18,18 +19,11 @@ function cleanDist(name: string) { } } -function runBuild(name: string) { - execSync(`rolldown -c configs/${name}.ts`, { - cwd: baseDir, - stdio: 'pipe', - }) -} - describe('Styled JSX Benchmark', () => { bench( '@rolldown/plugin-styled-jsx', () => { - runBuild('custom') + runBuild('custom', baseDir) }, { teardown: () => cleanDist('custom') }, ) @@ -37,7 +31,7 @@ describe('Styled JSX Benchmark', () => { bench( '@rolldown/plugin-babel', () => { - runBuild('babel') + runBuild('babel', baseDir) }, { teardown: () => cleanDist('babel') }, ) @@ -45,7 +39,7 @@ describe('Styled JSX Benchmark', () => { bench( '@rollup/plugin-swc', () => { - runBuild('swc') + runBuild('swc', baseDir) }, { teardown: () => cleanDist('swc') }, ) diff --git a/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts new file mode 100644 index 0000000..7728db5 --- /dev/null +++ b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts @@ -0,0 +1,21 @@ +import { describe, test } from 'vitest' +import { execSync } from 'node:child_process' +import { existsSync } from 'node:fs' +import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' + +const baseDir = resolve(import.meta.dirname, '..') +const componentsDir = resolve(baseDir, 'shared-app/src/components') + +if (!existsSync(componentsDir)) { + execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) +} + +describe('Styled JSX build', () => { + test.for(['custom', 'babel', 'swc'] as const)( + 'build:%s exits with code 0', + (name) => { + runBuild(name, baseDir) + }, + ) +}) diff --git a/packages/transform-imports/benchmark/bench/transform-imports.bench.ts b/packages/transform-imports/benchmark/bench/transform-imports.bench.ts index 352d5e1..c5f94ab 100644 --- a/packages/transform-imports/benchmark/bench/transform-imports.bench.ts +++ b/packages/transform-imports/benchmark/bench/transform-imports.bench.ts @@ -2,6 +2,7 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' import { existsSync, rmSync } from 'node:fs' import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') @@ -18,18 +19,11 @@ function cleanDist(name: string) { } } -function runBuild(name: string) { - execSync(`rolldown -c configs/${name}.ts`, { - cwd: baseDir, - stdio: 'pipe', - }) -} - describe('Transform Imports Benchmark', () => { bench( '@rolldown/plugin-transform-imports', () => { - runBuild('custom') + runBuild('custom', baseDir) }, { teardown: () => cleanDist('custom') }, ) @@ -37,7 +31,7 @@ describe('Transform Imports Benchmark', () => { bench( 'babel-plugin-transform-imports', () => { - runBuild('babel') + runBuild('babel', baseDir) }, { teardown: () => cleanDist('babel') }, ) @@ -45,7 +39,7 @@ describe('Transform Imports Benchmark', () => { bench( '@swc/plugin-transform-imports', () => { - runBuild('swc') + runBuild('swc', baseDir) }, { teardown: () => cleanDist('swc') }, ) diff --git a/packages/transform-imports/benchmark/bench/transform-imports.test.ts b/packages/transform-imports/benchmark/bench/transform-imports.test.ts new file mode 100644 index 0000000..ac9b18e --- /dev/null +++ b/packages/transform-imports/benchmark/bench/transform-imports.test.ts @@ -0,0 +1,21 @@ +import { describe, test } from 'vitest' +import { execSync } from 'node:child_process' +import { existsSync } from 'node:fs' +import { resolve } from 'node:path' +import { runBuild } from '@rolldown/benchmark-utils/run-build' + +const baseDir = resolve(import.meta.dirname, '..') +const modulesDir = resolve(baseDir, 'shared-app/src/modules') + +if (!existsSync(modulesDir)) { + execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) +} + +describe('Transform Imports build', () => { + test.for(['custom', 'babel', 'swc'] as const)( + 'build:%s exits with code 0', + (name) => { + runBuild(name, baseDir) + }, + ) +}) From 565102db8f15cef44a6556df307ccc65fc00401d Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 18 May 2026 16:28:28 +0900 Subject: [PATCH 2/6] chore: update --- internal-packages/benchmark-utils/src/run-build.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal-packages/benchmark-utils/src/run-build.ts b/internal-packages/benchmark-utils/src/run-build.ts index 39f315d..a8d4bdc 100644 --- a/internal-packages/benchmark-utils/src/run-build.ts +++ b/internal-packages/benchmark-utils/src/run-build.ts @@ -1,5 +1,6 @@ import { execSync } from 'node:child_process' import { Buffer } from 'node:buffer' +import { delimiter, resolve } from 'node:path' function asString(value: unknown): string { if (typeof value === 'string') return value @@ -8,10 +9,16 @@ function asString(value: unknown): string { } export function runBuild(configName: string, baseDir: string): void { + const localBin = resolve(baseDir, 'node_modules/.bin') + const env = { + ...process.env, + PATH: `${localBin}${delimiter}${process.env.PATH ?? ''}`, + } try { execSync(`rolldown -c configs/${configName}.ts`, { cwd: baseDir, stdio: 'pipe', + env, }) } catch (err) { const isObject = typeof err === 'object' && err !== null From 09fddcd3be3547be7c9d479f2ebf64edefd2d8bb Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 18 May 2026 16:52:20 +0900 Subject: [PATCH 3/6] chore: update --- packages/emotion/benchmark/vitest.config.ts | 1 + packages/jsx-remove-attributes/benchmark/vitest.config.ts | 1 + packages/styled-jsx/benchmark/vitest.config.ts | 1 + packages/transform-imports/benchmark/vitest.config.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/packages/emotion/benchmark/vitest.config.ts b/packages/emotion/benchmark/vitest.config.ts index f9cf58d..e837a11 100644 --- a/packages/emotion/benchmark/vitest.config.ts +++ b/packages/emotion/benchmark/vitest.config.ts @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-emotion', + testTimeout: 60_000, }, }) diff --git a/packages/jsx-remove-attributes/benchmark/vitest.config.ts b/packages/jsx-remove-attributes/benchmark/vitest.config.ts index bddd03d..7114f4e 100644 --- a/packages/jsx-remove-attributes/benchmark/vitest.config.ts +++ b/packages/jsx-remove-attributes/benchmark/vitest.config.ts @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-jsx-remove-attributes', + testTimeout: 60_000, }, }) diff --git a/packages/styled-jsx/benchmark/vitest.config.ts b/packages/styled-jsx/benchmark/vitest.config.ts index 083ee42..0948fe9 100644 --- a/packages/styled-jsx/benchmark/vitest.config.ts +++ b/packages/styled-jsx/benchmark/vitest.config.ts @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-styled-jsx', + testTimeout: 60_000, }, }) diff --git a/packages/transform-imports/benchmark/vitest.config.ts b/packages/transform-imports/benchmark/vitest.config.ts index bd4ac39..3491dce 100644 --- a/packages/transform-imports/benchmark/vitest.config.ts +++ b/packages/transform-imports/benchmark/vitest.config.ts @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-transform-imports', + testTimeout: 60_000, }, }) From 62feb00f69cd5214e1209611c39cb93635e4c305 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 18 May 2026 17:11:47 +0900 Subject: [PATCH 4/6] chore: update --- packages/emotion/benchmark/bench/emotion.bench.ts | 8 ++++++-- packages/emotion/benchmark/bench/emotion.test.ts | 6 +----- packages/emotion/benchmark/scripts/generate-app.ts | 5 ++++- packages/emotion/benchmark/vitest.config.ts | 1 - .../benchmark/bench/jsx-remove-attributes.bench.ts | 8 ++++++-- .../benchmark/bench/jsx-remove-attributes.test.ts | 6 +----- .../benchmark/scripts/generate-app.ts | 5 ++++- packages/jsx-remove-attributes/benchmark/vitest.config.ts | 1 - packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts | 8 ++++++-- packages/styled-jsx/benchmark/bench/styled-jsx.test.ts | 6 +----- packages/styled-jsx/benchmark/scripts/generate-app.ts | 5 ++++- packages/styled-jsx/benchmark/vitest.config.ts | 1 - .../benchmark/bench/transform-imports.bench.ts | 8 ++++++-- .../benchmark/bench/transform-imports.test.ts | 6 +----- .../transform-imports/benchmark/scripts/generate-app.ts | 5 ++++- packages/transform-imports/benchmark/vitest.config.ts | 1 - 16 files changed, 44 insertions(+), 36 deletions(-) diff --git a/packages/emotion/benchmark/bench/emotion.bench.ts b/packages/emotion/benchmark/bench/emotion.bench.ts index d30b9e5..46a279f 100644 --- a/packages/emotion/benchmark/bench/emotion.bench.ts +++ b/packages/emotion/benchmark/bench/emotion.bench.ts @@ -1,14 +1,18 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync, rmSync } from 'node:fs' +import { existsSync, readdirSync, rmSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') const componentsDir = resolve(baseDir, 'shared-app/src/components') +const expectedComponents = 100 -if (!existsSync(componentsDir)) { +const currentComponents = existsSync(componentsDir) + ? readdirSync(componentsDir).filter((f) => f.endsWith('.tsx')).length + : 0 +if (currentComponents !== expectedComponents) { execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) } diff --git a/packages/emotion/benchmark/bench/emotion.test.ts b/packages/emotion/benchmark/bench/emotion.test.ts index 828c89a..a0a5384 100644 --- a/packages/emotion/benchmark/bench/emotion.test.ts +++ b/packages/emotion/benchmark/bench/emotion.test.ts @@ -1,15 +1,11 @@ import { describe, test } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -const componentsDir = resolve(baseDir, 'shared-app/src/components') -if (!existsSync(componentsDir)) { - execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) -} +execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('Emotion build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/emotion/benchmark/scripts/generate-app.ts b/packages/emotion/benchmark/scripts/generate-app.ts index b4884c8..50ea8c7 100644 --- a/packages/emotion/benchmark/scripts/generate-app.ts +++ b/packages/emotion/benchmark/scripts/generate-app.ts @@ -274,7 +274,10 @@ function main() { mkdirSync(componentsDir, { recursive: true }) const components: Array<{ type: ComponentType; index: number }> = [] - const TOTAL = 100 + const totalArg = process.argv.find((a) => a.startsWith('--total=')) + const TOTAL = totalArg + ? Number.parseInt(totalArg.slice('--total='.length), 10) + : 100 const perType = Math.floor(TOTAL / COMPONENT_TYPES.length) const remainder = TOTAL % COMPONENT_TYPES.length diff --git a/packages/emotion/benchmark/vitest.config.ts b/packages/emotion/benchmark/vitest.config.ts index e837a11..f9cf58d 100644 --- a/packages/emotion/benchmark/vitest.config.ts +++ b/packages/emotion/benchmark/vitest.config.ts @@ -3,6 +3,5 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-emotion', - testTimeout: 60_000, }, }) diff --git a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts index c1df018..10d0819 100644 --- a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts +++ b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.bench.ts @@ -1,14 +1,18 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync, rmSync } from 'node:fs' +import { existsSync, readdirSync, rmSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') const componentsDir = resolve(baseDir, 'shared-app/src/components') +const expectedComponents = 100 -if (!existsSync(componentsDir)) { +const currentComponents = existsSync(componentsDir) + ? readdirSync(componentsDir).filter((f) => f.endsWith('.tsx')).length + : 0 +if (currentComponents !== expectedComponents) { execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) } diff --git a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts index 597f221..bff6d4b 100644 --- a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts +++ b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts @@ -1,15 +1,11 @@ import { describe, test } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -const componentsDir = resolve(baseDir, 'shared-app/src/components') -if (!existsSync(componentsDir)) { - execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) -} +execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('JSX Remove Attributes build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts b/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts index d77da0a..3a953c0 100644 --- a/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts +++ b/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts @@ -184,7 +184,10 @@ function main() { mkdirSync(componentsDir, { recursive: true }) const components: Array<{ type: ComponentType; index: number }> = [] - const TOTAL = 100 + const totalArg = process.argv.find((a) => a.startsWith('--total=')) + const TOTAL = totalArg + ? Number.parseInt(totalArg.slice('--total='.length), 10) + : 100 const perType = Math.floor(TOTAL / COMPONENT_TYPES.length) const remainder = TOTAL % COMPONENT_TYPES.length diff --git a/packages/jsx-remove-attributes/benchmark/vitest.config.ts b/packages/jsx-remove-attributes/benchmark/vitest.config.ts index 7114f4e..bddd03d 100644 --- a/packages/jsx-remove-attributes/benchmark/vitest.config.ts +++ b/packages/jsx-remove-attributes/benchmark/vitest.config.ts @@ -3,6 +3,5 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-jsx-remove-attributes', - testTimeout: 60_000, }, }) diff --git a/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts b/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts index df4214b..1b2a118 100644 --- a/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts +++ b/packages/styled-jsx/benchmark/bench/styled-jsx.bench.ts @@ -1,14 +1,18 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync, rmSync } from 'node:fs' +import { existsSync, readdirSync, rmSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') const componentsDir = resolve(baseDir, 'shared-app/src/components') +const expectedComponents = 100 -if (!existsSync(componentsDir)) { +const currentComponents = existsSync(componentsDir) + ? readdirSync(componentsDir).filter((f) => f.endsWith('.tsx')).length + : 0 +if (currentComponents !== expectedComponents) { execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) } diff --git a/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts index 7728db5..41409c4 100644 --- a/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts +++ b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts @@ -1,15 +1,11 @@ import { describe, test } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -const componentsDir = resolve(baseDir, 'shared-app/src/components') -if (!existsSync(componentsDir)) { - execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) -} +execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('Styled JSX build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/styled-jsx/benchmark/scripts/generate-app.ts b/packages/styled-jsx/benchmark/scripts/generate-app.ts index 49e5d3a..81903e8 100644 --- a/packages/styled-jsx/benchmark/scripts/generate-app.ts +++ b/packages/styled-jsx/benchmark/scripts/generate-app.ts @@ -275,7 +275,10 @@ function main() { mkdirSync(componentsDir, { recursive: true }) const components: Array<{ type: ComponentType; index: number }> = [] - const TOTAL = 100 + const totalArg = process.argv.find((a) => a.startsWith('--total=')) + const TOTAL = totalArg + ? Number.parseInt(totalArg.slice('--total='.length), 10) + : 100 const perType = Math.floor(TOTAL / COMPONENT_TYPES.length) const remainder = TOTAL % COMPONENT_TYPES.length diff --git a/packages/styled-jsx/benchmark/vitest.config.ts b/packages/styled-jsx/benchmark/vitest.config.ts index 0948fe9..083ee42 100644 --- a/packages/styled-jsx/benchmark/vitest.config.ts +++ b/packages/styled-jsx/benchmark/vitest.config.ts @@ -3,6 +3,5 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-styled-jsx', - testTimeout: 60_000, }, }) diff --git a/packages/transform-imports/benchmark/bench/transform-imports.bench.ts b/packages/transform-imports/benchmark/bench/transform-imports.bench.ts index c5f94ab..c231c99 100644 --- a/packages/transform-imports/benchmark/bench/transform-imports.bench.ts +++ b/packages/transform-imports/benchmark/bench/transform-imports.bench.ts @@ -1,14 +1,18 @@ import { bench, describe } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync, rmSync } from 'node:fs' +import { existsSync, readdirSync, rmSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') const distBase = resolve(baseDir, 'dist') const modulesDir = resolve(baseDir, 'shared-app/src/modules') +const expectedModules = 100 -if (!existsSync(modulesDir)) { +const currentModules = existsSync(modulesDir) + ? readdirSync(modulesDir).filter((f) => f.endsWith('.js')).length + : 0 +if (currentModules !== expectedModules) { execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) } diff --git a/packages/transform-imports/benchmark/bench/transform-imports.test.ts b/packages/transform-imports/benchmark/bench/transform-imports.test.ts index ac9b18e..374ab9a 100644 --- a/packages/transform-imports/benchmark/bench/transform-imports.test.ts +++ b/packages/transform-imports/benchmark/bench/transform-imports.test.ts @@ -1,15 +1,11 @@ import { describe, test } from 'vitest' import { execSync } from 'node:child_process' -import { existsSync } from 'node:fs' import { resolve } from 'node:path' import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -const modulesDir = resolve(baseDir, 'shared-app/src/modules') -if (!existsSync(modulesDir)) { - execSync('pnpm generate', { cwd: baseDir, stdio: 'inherit' }) -} +execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('Transform Imports build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/transform-imports/benchmark/scripts/generate-app.ts b/packages/transform-imports/benchmark/scripts/generate-app.ts index 59c8d51..8782c12 100644 --- a/packages/transform-imports/benchmark/scripts/generate-app.ts +++ b/packages/transform-imports/benchmark/scripts/generate-app.ts @@ -166,7 +166,10 @@ function main() { if (existsSync(appDir)) rmSync(appDir, { recursive: true }) mkdirSync(join(appDir, 'modules'), { recursive: true }) - const TOTAL = 100 + const totalArg = process.argv.find((a) => a.startsWith('--total=')) + const TOTAL = totalArg + ? Number.parseInt(totalArg.slice('--total='.length), 10) + : 100 const files: string[] = [] for (let i = 0; i < TOTAL; i++) { diff --git a/packages/transform-imports/benchmark/vitest.config.ts b/packages/transform-imports/benchmark/vitest.config.ts index 3491dce..bd4ac39 100644 --- a/packages/transform-imports/benchmark/vitest.config.ts +++ b/packages/transform-imports/benchmark/vitest.config.ts @@ -3,6 +3,5 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { name: 'benchmark-transform-imports', - testTimeout: 60_000, }, }) From 6bcbfd261137f611b2b2777772f5f70fcf44295a Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 18 May 2026 17:22:38 +0900 Subject: [PATCH 5/6] chore: update --- packages/emotion/benchmark/bench/emotion.test.ts | 1 + .../benchmark/bench/jsx-remove-attributes.test.ts | 1 + packages/styled-jsx/benchmark/bench/styled-jsx.test.ts | 1 + .../transform-imports/benchmark/bench/transform-imports.test.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/packages/emotion/benchmark/bench/emotion.test.ts b/packages/emotion/benchmark/bench/emotion.test.ts index a0a5384..e3a9f5a 100644 --- a/packages/emotion/benchmark/bench/emotion.test.ts +++ b/packages/emotion/benchmark/bench/emotion.test.ts @@ -10,6 +10,7 @@ execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('Emotion build', () => { test.for(['custom', 'babel', 'swc'] as const)( 'build:%s exits with code 0', + { timeout: 30_000 }, (name) => { runBuild(name, baseDir) }, diff --git a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts index bff6d4b..aa4c0e0 100644 --- a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts +++ b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts @@ -10,6 +10,7 @@ execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('JSX Remove Attributes build', () => { test.for(['custom', 'babel', 'swc'] as const)( 'build:%s exits with code 0', + { timeout: 30_000 }, (name) => { runBuild(name, baseDir) }, diff --git a/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts index 41409c4..9f5cfab 100644 --- a/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts +++ b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts @@ -10,6 +10,7 @@ execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('Styled JSX build', () => { test.for(['custom', 'babel', 'swc'] as const)( 'build:%s exits with code 0', + { timeout: 30_000 }, (name) => { runBuild(name, baseDir) }, diff --git a/packages/transform-imports/benchmark/bench/transform-imports.test.ts b/packages/transform-imports/benchmark/bench/transform-imports.test.ts index 374ab9a..69c3963 100644 --- a/packages/transform-imports/benchmark/bench/transform-imports.test.ts +++ b/packages/transform-imports/benchmark/bench/transform-imports.test.ts @@ -10,6 +10,7 @@ execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) describe('Transform Imports build', () => { test.for(['custom', 'babel', 'swc'] as const)( 'build:%s exits with code 0', + { timeout: 30_000 }, (name) => { runBuild(name, baseDir) }, From a1ede798686934be51c677e5470c6181d6038433 Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Mon, 18 May 2026 17:28:35 +0900 Subject: [PATCH 6/6] chore: update --- internal-packages/benchmark-utils/src/run-build.ts | 13 +++---------- packages/emotion/benchmark/bench/emotion.test.ts | 5 ++++- packages/emotion/benchmark/scripts/generate-app.ts | 13 +++++++------ .../benchmark/bench/jsx-remove-attributes.test.ts | 5 ++++- .../benchmark/scripts/generate-app.ts | 13 +++++++------ .../styled-jsx/benchmark/bench/styled-jsx.test.ts | 5 ++++- .../styled-jsx/benchmark/scripts/generate-app.ts | 13 +++++++------ .../benchmark/bench/transform-imports.test.ts | 5 ++++- .../benchmark/scripts/generate-app.ts | 13 +++++++------ 9 files changed, 47 insertions(+), 38 deletions(-) diff --git a/internal-packages/benchmark-utils/src/run-build.ts b/internal-packages/benchmark-utils/src/run-build.ts index a8d4bdc..feb8381 100644 --- a/internal-packages/benchmark-utils/src/run-build.ts +++ b/internal-packages/benchmark-utils/src/run-build.ts @@ -22,16 +22,9 @@ export function runBuild(configName: string, baseDir: string): void { }) } catch (err) { const isObject = typeof err === 'object' && err !== null - const status = - isObject && 'status' in err && typeof err.status === 'number' - ? err.status - : null - const stdout = asString( - isObject && 'stdout' in err ? err.stdout : undefined, - ) - const stderr = asString( - isObject && 'stderr' in err ? err.stderr : undefined, - ) + const status = isObject && 'status' in err && typeof err.status === 'number' ? err.status : null + const stdout = asString(isObject && 'stdout' in err ? err.stdout : undefined) + const stderr = asString(isObject && 'stderr' in err ? err.stderr : undefined) throw new Error( `build:${configName} failed (exit ${status ?? 'unknown'}):\n${stdout}${stderr}`, { cause: err }, diff --git a/packages/emotion/benchmark/bench/emotion.test.ts b/packages/emotion/benchmark/bench/emotion.test.ts index e3a9f5a..cbb6865 100644 --- a/packages/emotion/benchmark/bench/emotion.test.ts +++ b/packages/emotion/benchmark/bench/emotion.test.ts @@ -5,7 +5,10 @@ import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) +execSync('pnpm generate -- --total=10 --silent', { + cwd: baseDir, + stdio: 'inherit', +}) describe('Emotion build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/emotion/benchmark/scripts/generate-app.ts b/packages/emotion/benchmark/scripts/generate-app.ts index 50ea8c7..db1333a 100644 --- a/packages/emotion/benchmark/scripts/generate-app.ts +++ b/packages/emotion/benchmark/scripts/generate-app.ts @@ -275,9 +275,8 @@ function main() { const components: Array<{ type: ComponentType; index: number }> = [] const totalArg = process.argv.find((a) => a.startsWith('--total=')) - const TOTAL = totalArg - ? Number.parseInt(totalArg.slice('--total='.length), 10) - : 100 + const TOTAL = totalArg ? Number.parseInt(totalArg.slice('--total='.length), 10) : 100 + const silent = process.argv.includes('--silent') const perType = Math.floor(TOTAL / COMPONENT_TYPES.length) const remainder = TOTAL % COMPONENT_TYPES.length @@ -296,9 +295,11 @@ function main() { .join('\n') writeFileSync(join(componentsDir, 'index.ts'), exports + '\n') - console.log(`Generated ${components.length} components in ${componentsDir}`) - for (const type of COMPONENT_TYPES) { - console.log(` ${type}: ${components.filter((c) => c.type === type).length}`) + if (!silent) { + console.log(`Generated ${components.length} components in ${componentsDir}`) + for (const type of COMPONENT_TYPES) { + console.log(` ${type}: ${components.filter((c) => c.type === type).length}`) + } } } diff --git a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts index aa4c0e0..f022749 100644 --- a/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts +++ b/packages/jsx-remove-attributes/benchmark/bench/jsx-remove-attributes.test.ts @@ -5,7 +5,10 @@ import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) +execSync('pnpm generate -- --total=10 --silent', { + cwd: baseDir, + stdio: 'inherit', +}) describe('JSX Remove Attributes build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts b/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts index 3a953c0..51f97fb 100644 --- a/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts +++ b/packages/jsx-remove-attributes/benchmark/scripts/generate-app.ts @@ -185,9 +185,8 @@ function main() { const components: Array<{ type: ComponentType; index: number }> = [] const totalArg = process.argv.find((a) => a.startsWith('--total=')) - const TOTAL = totalArg - ? Number.parseInt(totalArg.slice('--total='.length), 10) - : 100 + const TOTAL = totalArg ? Number.parseInt(totalArg.slice('--total='.length), 10) : 100 + const silent = process.argv.includes('--silent') const perType = Math.floor(TOTAL / COMPONENT_TYPES.length) const remainder = TOTAL % COMPONENT_TYPES.length @@ -206,9 +205,11 @@ function main() { .join('\n') writeFileSync(join(componentsDir, 'index.ts'), exports + '\n') - console.log(`Generated ${components.length} components in ${componentsDir}`) - for (const type of COMPONENT_TYPES) { - console.log(` ${type}: ${components.filter((c) => c.type === type).length}`) + if (!silent) { + console.log(`Generated ${components.length} components in ${componentsDir}`) + for (const type of COMPONENT_TYPES) { + console.log(` ${type}: ${components.filter((c) => c.type === type).length}`) + } } } diff --git a/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts index 9f5cfab..e8f7754 100644 --- a/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts +++ b/packages/styled-jsx/benchmark/bench/styled-jsx.test.ts @@ -5,7 +5,10 @@ import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) +execSync('pnpm generate -- --total=10 --silent', { + cwd: baseDir, + stdio: 'inherit', +}) describe('Styled JSX build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/styled-jsx/benchmark/scripts/generate-app.ts b/packages/styled-jsx/benchmark/scripts/generate-app.ts index 81903e8..d35b598 100644 --- a/packages/styled-jsx/benchmark/scripts/generate-app.ts +++ b/packages/styled-jsx/benchmark/scripts/generate-app.ts @@ -276,9 +276,8 @@ function main() { const components: Array<{ type: ComponentType; index: number }> = [] const totalArg = process.argv.find((a) => a.startsWith('--total=')) - const TOTAL = totalArg - ? Number.parseInt(totalArg.slice('--total='.length), 10) - : 100 + const TOTAL = totalArg ? Number.parseInt(totalArg.slice('--total='.length), 10) : 100 + const silent = process.argv.includes('--silent') const perType = Math.floor(TOTAL / COMPONENT_TYPES.length) const remainder = TOTAL % COMPONENT_TYPES.length @@ -297,9 +296,11 @@ function main() { .join('\n') writeFileSync(join(componentsDir, 'index.ts'), exports + '\n') - console.log(`Generated ${components.length} components in ${componentsDir}`) - for (const type of COMPONENT_TYPES) { - console.log(` ${type}: ${components.filter((c) => c.type === type).length}`) + if (!silent) { + console.log(`Generated ${components.length} components in ${componentsDir}`) + for (const type of COMPONENT_TYPES) { + console.log(` ${type}: ${components.filter((c) => c.type === type).length}`) + } } } diff --git a/packages/transform-imports/benchmark/bench/transform-imports.test.ts b/packages/transform-imports/benchmark/bench/transform-imports.test.ts index 69c3963..c1d136e 100644 --- a/packages/transform-imports/benchmark/bench/transform-imports.test.ts +++ b/packages/transform-imports/benchmark/bench/transform-imports.test.ts @@ -5,7 +5,10 @@ import { runBuild } from '@rolldown/benchmark-utils/run-build' const baseDir = resolve(import.meta.dirname, '..') -execSync('pnpm generate -- --total=10', { cwd: baseDir, stdio: 'inherit' }) +execSync('pnpm generate -- --total=10 --silent', { + cwd: baseDir, + stdio: 'inherit', +}) describe('Transform Imports build', () => { test.for(['custom', 'babel', 'swc'] as const)( diff --git a/packages/transform-imports/benchmark/scripts/generate-app.ts b/packages/transform-imports/benchmark/scripts/generate-app.ts index 8782c12..c48bad5 100644 --- a/packages/transform-imports/benchmark/scripts/generate-app.ts +++ b/packages/transform-imports/benchmark/scripts/generate-app.ts @@ -167,9 +167,8 @@ function main() { mkdirSync(join(appDir, 'modules'), { recursive: true }) const totalArg = process.argv.find((a) => a.startsWith('--total=')) - const TOTAL = totalArg - ? Number.parseInt(totalArg.slice('--total='.length), 10) - : 100 + const TOTAL = totalArg ? Number.parseInt(totalArg.slice('--total='.length), 10) : 100 + const silent = process.argv.includes('--silent') const files: string[] = [] for (let i = 0; i < TOTAL; i++) { @@ -188,9 +187,11 @@ function main() { .join('\n') writeFileSync(join(appDir, 'index.js'), entry + '\n') - console.log(`Generated ${TOTAL} modules in ${appDir}/modules/`) - for (const type of PATTERN_TYPES) { - console.log(` Pattern distribution includes: ${type}`) + if (!silent) { + console.log(`Generated ${TOTAL} modules in ${appDir}/modules/`) + for (const type of PATTERN_TYPES) { + console.log(` Pattern distribution includes: ${type}`) + } } }