-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { type Compiler, type Compilation, rspack } from "@rspack/core"; | ||
import { beforeAll, bench, describe } from "vitest"; | ||
import rspackConfig from "./fixtures/ts-react/rspack.config"; | ||
|
||
let thisCompiler: Compiler; | ||
let theCompilation: Compilation; | ||
|
||
beforeAll(() => { | ||
return new Promise((resolve, reject) => { | ||
thisCompiler = rspack( | ||
{ | ||
...rspackConfig, | ||
mode: "production", | ||
plugins: [ | ||
...(rspackConfig.plugins ?? []), | ||
compiler => { | ||
compiler.hooks.compilation.tap("PLUGIN", compilation => { | ||
theCompilation = compilation; | ||
}); | ||
} | ||
] | ||
} | ||
); | ||
thisCompiler.run((err, stats) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
if (stats?.hasErrors()) { | ||
reject(new Error(stats.toString({}))); | ||
} | ||
resolve(undefined); | ||
}); | ||
for (const module of theCompilation.modules) {} | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
return new Promise((resolve, reject) => { | ||
thisCompiler.run((err, stats) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
if (stats?.hasErrors()) { | ||
reject(new Error(stats.toString({}))); | ||
} | ||
resolve(undefined); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("TypeScript React project HMR", () => { | ||
bench("traverse modules (HMR)", () => { | ||
for (const module of theCompilation.modules) {} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters