Open SoonIter opened 2 days ago
https://github.com/SoonIter/rspack-rollup-treeshake-repro/tree/investigation
// index.ts
import { Arrow3 } from './a';
console.log(Arrow3);
// a.ts
var isOnline = "online" === "online";
import { qux } from './qux'
function a() {}
function b() {}
var ManGlb3;
if (isOnline) {
ManGlb3 = a();
} else {
ManGlb3 = b();
console.log(qux);
}
var Arrow3;
if (isOnline) {
Arrow3 = 3;
} else {
Arrow3 = 4;
console.log(qux);
}
export { ManGlb3, Arrow3 }
// qux.ts
export const qux = 'QUX';
var Arrow3;
{
Arrow3 = 3;
}
console.log(Arrow3);
;// CONCATENATED MODULE: ./src/qux.ts
const qux = 'QUX';
;// CONCATENATED MODULE: ./src/a.ts
var isOnline = "online" === "online";
function a() {}
function b() {}
var ManGlb3;
if (isOnline) {
ManGlb3 = a();
} else {
ManGlb3 = b();
console.log(qux);
}
var Arrow3;
if (isOnline) {
Arrow3 = 3;
} else {
Arrow3 = 4;
console.log(qux);
}
;// CONCATENATED MODULE: ./src/index.ts
console.log(Arrow3);
then, rspack would use terser to DCE, once the concatenatedModule
bailouts, the dce effect will be lower than rollup a lot
System Info
System: OS: macOS 14.6.1 CPU: (10) arm64 Apple M1 Pro Memory: 124.89 MB / 32.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 131.0.6778.70 Chrome Canary: 133.0.6847.0 Safari: 17.6
Details
DCE analysis in one big esm file, compared with rollup
https://github.com/SoonIter/rspack-rollup-treeshake-repro
Result
rsbuild 3875kb > vite(rollup) 812kb
rsbuild
vite(rollup)
Reproduce link
https://github.com/SoonIter/rspack-rollup-treeshake-repro
Reproduce Steps