Skip to content

Commit

Permalink
feat: cases support rspack 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykingxyz committed Nov 23, 2023
1 parent 7b3bb85 commit 4c1d0cd
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 797 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
- name: Check Threshold
run: |
result="${{ steps.print-compare-results.outputs.diff-result }}";
result='${{ steps.print-compare-results.outputs.diff-result }}';
if [[ $result =~ "Threshold exceeded" ]]; then
echo "Some benchmark cases exceed the threshold, please visit the previous step for more information"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled_bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: node bin/upload.js ${{ secrets.GITHUB_TOKEN }}
- name: Check Threshold
run: |
result="${{ steps.print-compare-results.outputs.diff-result }}";
result='${{ steps.print-compare-results.outputs.diff-result }}';
if [[ $result =~ "Threshold exceeded" ]]; then
echo "Some benchmark cases exceed the threshold, please visit the previous step for more information"
exit 1
Expand Down
4 changes: 1 addition & 3 deletions bin/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ 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"
"threejs_production-mode_10x"
];

(async () => {
Expand Down
51 changes: 50 additions & 1 deletion cases/10000/rspack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require("path");
const rspack = require("@rspack/core");
const ReactRefreshPlugin = require("@rspack/plugin-react-refresh");

const prod = process.env.NODE_ENV === "production";
/** @type {import("@rspack/cli").Configuration} */
module.exports = {
resolve: {
Expand All @@ -10,8 +12,55 @@ module.exports = {
plugins: [
new rspack.HtmlRspackPlugin({
template: path.resolve(__dirname, "./index.html")
})
}),
new ReactRefreshPlugin()
],
module: {
rules: [
{
test: /\.(j|t)s$/,
exclude: [/[\\/]node_modules[\\/]/],
loader: "builtin:swc-loader",
options: {
sourceMap: true,
jsc: {
parser: {
syntax: "typescript"
},
externalHelpers: true
},
env: {
targets: "Chrome >= 48"
}
}
},
{
test: /\.(j|t)sx$/,
loader: "builtin:swc-loader",
exclude: [/[\\/]node_modules[\\/]/],
options: {
sourceMap: true,
jsc: {
parser: {
syntax: "typescript",
tsx: true
},
transform: {
react: {
runtime: "automatic",
development: !prod,
refresh: !prod
}
},
externalHelpers: true
},
env: {
targets: "Chrome >= 48"
}
}
}
]
},
optimization: {
splitChunks: {
chunks: "all",
Expand Down
59 changes: 0 additions & 59 deletions lib/addons/builtin-swc-loader.js

This file was deleted.

9 changes: 9 additions & 0 deletions lib/scenarios/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ module.exports.plugins.push(new (require("../../lib/scenarios/build-plugin.cjs")
const rspackDir =
process.env.RSPACK_DIR || path.resolve(rootDir, ".rspack");
console.log("create rspack package link");
await runCommand("mkdir", [
"-p",
path.resolve(rootDir, "node_modules/@rspack")
]);
await runCommand("ln", [
"-nsf",
path.resolve(rspackDir, "packages/rspack"),
Expand All @@ -112,6 +116,11 @@ module.exports.plugins.push(new (require("../../lib/scenarios/build-plugin.cjs")
path.resolve(rspackDir, "packages/rspack-cli"),
path.resolve(rootDir, "node_modules/@rspack/cli")
]);
await runCommand("ln", [
"-nsf",
path.resolve(rspackDir, "packages/rspack-plugin-react-refresh"),
path.resolve(rootDir, "node_modules/@rspack/plugin-react-refresh")
]);
},
async warmup(ctx) {
console.log("run rspack with args:", ctx.rspackArgs);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"type": "module",
"dependencies": {
"@icon-park/react": "^1.4.2",
"@rspack/plugin-react-refresh": "^0.3.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-refresh": "^0.14.0"
Expand Down
Loading

0 comments on commit 4c1d0cd

Please sign in to comment.