diff --git a/README.md b/README.md index d6d63ed8..98a2f4af 100644 --- a/README.md +++ b/README.md @@ -163,4 +163,11 @@ interface Addon { 2. move the project dependencies to global package.json 3. add `rspack.config.js` to make the project runnable by rspack 4. add `hmr.js` to make the project support hmr changes -5. try run `node bin/bench.js _` to test +5. try run `RSPACK_CLI_BIN= node bin/bench.js _` to test + +## How to create a addon + +1. create your addons in `/lib/addons` with kebab case like "a-b-c.js" +2. export default a class that extends `/lib/addons/common` and implement the hooks you want to listen +3. try run `RSPACK_CLI_BIN= node bin/bench.js _` to test +4. if you want to run some benchmarkName by default, you can add it to `defaultBenchmarkNames` in `/bin/bench.js` diff --git a/bin/bench.js b/bin/bench.js index 7ee4ddf0..17bb4fc6 100644 --- a/bin/bench.js +++ b/bin/bench.js @@ -6,21 +6,22 @@ import { run, formatResultTable } from "../lib/index.js"; const [, , ...benchmarkNames] = process.argv; const rootDir = resolve(fileURLToPath(import.meta.url), "../.."); +const defaultBenchmarkNames = [ + "10000_development-mode", + "10000_development-mode_hmr", + "10000_production-mode", + "10000_production-mode_builtin-swc-loader", + "threejs_development-mode_10x", + "threejs_development-mode_10x_hmr", + "threejs_production-mode_10x", + "threejs_production-mode_builtin-swc-loader_10x" +]; (async () => { await mkdir(resolve(rootDir, "output"), { recursive: true }); const benchmarks = benchmarkNames.length ? benchmarkNames - : [ - "10000_development-mode", - "10000_development-mode_hmr", - "10000_production-mode", - "10000_production-mode_builtin-swc-loader", - "threejs_development-mode_10x", - "threejs_development-mode_10x_hmr", - "threejs_production-mode_10x", - "threejs_production-mode_builtin-swc-loader_10x" - ]; + : defaultBenchmarkNames; for (const item of benchmarks) { const result = await run(item); console.log(`${item} result is:`);