Skip to content

Commit

Permalink
test: remove old treeshaking (#6537)
Browse files Browse the repository at this point in the history
* test: remove old tree shaking

* test: remove old tree shaking

* test: remove old tree shaking
  • Loading branch information
LingyuCoder authored May 15, 2024
1 parent 6087cbb commit f65aae4
Show file tree
Hide file tree
Showing 290 changed files with 506 additions and 4,390 deletions.
14 changes: 2 additions & 12 deletions packages/rspack-test-tools/src/case/treeshaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,12 @@ const creator = new BasicCaseCreator({
clean: true,
describe: false,
description(name, step) {
if (step === 0) {
return `${name} with builtin.treeShaking should match snapshot`;
} else {
return `${name} with newTreeshaking should match snapshot`;
}
return `${name} with newTreeshaking should match snapshot`;
},
steps: ({ name }) => [
new RspackTreeShakingProcessor({
name,
snapshot: "output.snap.txt",
type: "builtin"
}),
new RspackTreeShakingProcessor({
name,
snapshot: "new_treeshaking.snap.txt",
type: "new"
snapshot: "treeshaking.snap.txt"
})
]
});
Expand Down
35 changes: 11 additions & 24 deletions packages/rspack-test-tools/src/processor/treeshaking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,31 @@ import { SnapshotProcessor } from "./snapshot";
export interface IRspackTreeShakingProcessorOptions {
name: string;
snapshot: string;
type: "new" | "builtin";
}

export class RspackTreeShakingProcessor extends SnapshotProcessor<ECompilerType.Rspack> {
constructor(
protected _treeShakingOptions: IRspackTreeShakingProcessorOptions
) {
super({
configFiles: ["rspack.config.js", "webpack.config.js"],
snapshot: _treeShakingOptions.snapshot,
compilerType: ECompilerType.Rspack,
defaultOptions: RspackBuiltinProcessor.defaultOptions,
overrideOptions: RspackTreeShakingProcessor.overrideOptions(
_treeShakingOptions.type
),
overrideOptions: RspackTreeShakingProcessor.overrideOptions,
name: _treeShakingOptions.name,
runable: false
});
}

static overrideOptions(type: IRspackTreeShakingProcessorOptions["type"]) {
return (
context: ITestContext,
options: TCompilerOptions<ECompilerType.Rspack>
) => {
options.target = options.target || ["web", "es2022"];
if (type === "new") {
options.optimization ??= {};
options.optimization.providedExports = true;
options.optimization.innerGraph = true;
options.optimization.usedExports = true;

options.builtins ??= {};
options.builtins.treeShaking = false;
} else {
options.experiments ??= {};
options.experiments.rspackFuture ??= {};
options.experiments.rspackFuture.newTreeshaking = false;
}
};
static overrideOptions(
context: ITestContext,
options: TCompilerOptions<ECompilerType.Rspack>
) {
options.target = options.target || ["web", "es2022"];
options.optimization ??= {};
options.optimization.providedExports = true;
options.optimization.innerGraph = true;
options.optimization.usedExports = true;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
sideEffects: true
},
builtins: {
treeShaking: true,
define: {
"process.env.NODE_ENV": "'development'"
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
sideEffects: true
},
builtins: {
treeShaking: true,
define: {
"process.env.NODE_ENV": "'development'"
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
sideEffects: true
},
builtins: {
treeShaking: true,
define: {
"process.env.NODE_ENV": "'development'"
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = {
sideEffects: true
},
builtins: {
treeShaking: true,
define: {
"process.env.NODE_ENV": "'development'"
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
optimization: {
sideEffects: true
},
builtins: {
define: {
"process.env.NODE_ENV": "'development'"
}
}
};
Loading

2 comments on commit f65aae4

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-05-15 3ee5df7) Current Change
10000_development-mode + exec 2.7 s ± 29 ms 2.7 s ± 19 ms +0.19 %
10000_development-mode_hmr + exec 709 ms ± 5.9 ms 710 ms ± 4.1 ms +0.23 %
10000_production-mode + exec 2.48 s ± 16 ms 2.5 s ± 24 ms +0.83 %
arco-pro_development-mode + exec 2.48 s ± 59 ms 2.46 s ± 88 ms -0.92 %
arco-pro_development-mode_hmr + exec 433 ms ± 2.3 ms 433 ms ± 3.4 ms +0.12 %
arco-pro_development-mode_hmr_intercept-plugin + exec 441 ms ± 1.7 ms 442 ms ± 2 ms +0.19 %
arco-pro_development-mode_intercept-plugin + exec 3.28 s ± 88 ms 3.29 s ± 64 ms +0.53 %
arco-pro_production-mode + exec 4.05 s ± 133 ms 4.07 s ± 101 ms +0.40 %
arco-pro_production-mode_intercept-plugin + exec 4.89 s ± 80 ms 4.89 s ± 84 ms +0.16 %
threejs_development-mode_10x + exec 1.98 s ± 16 ms 1.98 s ± 9.8 ms -0.04 %
threejs_development-mode_10x_hmr + exec 775 ms ± 3.3 ms 774 ms ± 3 ms -0.02 %
threejs_production-mode_10x + exec 5.19 s ± 33 ms 5.19 s ± 18 ms -0.05 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs, ubuntu-latest ❌ failure
_selftest, ubuntu-latest ✅ success
nx, ubuntu-latest ✅ success
rspress, ubuntu-latest ✅ success
rsbuild, ubuntu-latest ❌ failure
compat, ubuntu-latest ✅ success
examples, ubuntu-latest ✅ success

Please sign in to comment.