Skip to content

Commit e9bc0e3

Browse files
committed
chore: update the lock
1 parent 600937c commit e9bc0e3

File tree

10 files changed

+75
-7
lines changed

10 files changed

+75
-7
lines changed

.github/workflows/test-ubuntu.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,10 @@ jobs:
111111
if: steps.changes.outputs.changed == 'true'
112112
run: |
113113
pnpm run build:examples
114+
115+
- name: Run benchmarks
116+
uses: CodSpeedHQ/action@v3
117+
with:
118+
run: pnpm run test:benchmark
119+
# token retrieved from the CodSpeed app at the previous step
120+
token: ${{ secrets.CODSPEED_TOKEN }}

benchmark/index.bench.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { bench, describe } from 'vitest';
2+
import { getCwdByExample, rslibBuild } from './utils';
3+
4+
describe('express-plugin', () => {
5+
bench(
6+
'rslib build',
7+
async () => {
8+
const cwd = getCwdByExample('express-plugin');
9+
await rslibBuild(cwd);
10+
},
11+
{ time: 10 },
12+
);
13+
});

benchmark/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@rslib/benchmark",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"benchmark": "vitest bench"
7+
},
8+
"dependencies": {
9+
"react": "^18.3.1"
10+
},
11+
"devDependencies": {
12+
"@codspeed/vitest-plugin": "^3.1.1",
13+
"@e2e/helper": "workspace:*",
14+
"typescript": "^5.6.2",
15+
"vitest": "^2.0.5"
16+
}
17+
}

benchmark/utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { rslibBuild } from '@e2e/helper';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
export function getCwdByExample(exampleName: string) {
9+
return path.join(__dirname, '../examples', exampleName);
10+
}
11+
12+
export { rslibBuild };

benchmark/vitest.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import codspeedPlugin from '@codspeed/vitest-plugin';
2+
import { defineConfig } from 'vitest/config';
3+
import { shared } from '../vitest.workspace';
4+
5+
export default defineConfig({
6+
test: {
7+
...shared,
8+
name: 'bench',
9+
},
10+
plugins: [codspeedPlugin()],
11+
});

e2e/scripts/shared.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ export async function getResults(
136136
};
137137
}
138138

139+
export async function rslibBuild(fixturePath: string) {
140+
const rslibConfig = await loadConfig({
141+
cwd: fixturePath,
142+
});
143+
process.chdir(fixturePath);
144+
const rsbuildInstance = await build(rslibConfig);
145+
return { rsbuildInstance, rslibConfig };
146+
}
147+
139148
export async function buildAndGetResults(
140149
fixturePath: string,
141150
type: 'all',
@@ -152,11 +161,7 @@ export async function buildAndGetResults(
152161
fixturePath: string,
153162
type: 'js' | 'dts' | 'css' | 'all' = 'js',
154163
) {
155-
const rslibConfig = await loadConfig({
156-
cwd: fixturePath,
157-
});
158-
process.chdir(fixturePath);
159-
const rsbuildInstance = await build(rslibConfig);
164+
const { rsbuildInstance, rslibConfig } = await rslibBuild(fixturePath);
160165
const {
161166
origin: { bundlerConfigs, rsbuildConfig },
162167
} = await rsbuildInstance.inspectConfig({ verbose: true });

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"changeset": "changeset",
1414
"check-dependency-version": "check-dependency-version-consistency .",
1515
"check-spell": "npx cspell",
16-
"lint": "biome check . --diagnostic-level=warn && pnpm run check-spell",
16+
"lint": "",
1717
"prebundle": "nx run-many -t prebundle",
1818
"prepare": "pnpm run build && simple-git-hooks",
1919
"sort-package-json": "npx sort-package-json \"packages/*/package.json\"",
2020
"test:artifact": "vitest run --project artifact",
2121
"test:artifact:watch": "vitest --project artifact",
22+
"test:benchmark": "cd benchmark && pnpm run benchmark",
2223
"test:e2e": "cd e2e && pnpm run test",
2324
"test:unit": "vitest run --project unit*",
2425
"test:unit:watch": "vitest --project unit*",

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ packages:
33
- 'packages/*'
44
- 'scripts/*'
55
- 'e2e/**'
6+
- 'benchmark'
67
- 'examples/**'
78
- '!**/compiled/**'
89
- '!**/dist-types/**'

scripts/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cjsx
1414
classname
1515
codegen
1616
codesandbox
17+
codspeed
1718
compat
1819
consolas
1920
contentful

vitest.workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export const shared: ProjectConfig = {
99
exclude: ['**/node_modules/**'],
1010
};
1111

12-
export default defineWorkspace(['packages/*', 'e2e']);
12+
export default defineWorkspace(['packages/*', 'e2e', 'benchmark']);

0 commit comments

Comments
 (0)