Skip to content

Commit

Permalink
fix: enable rollup default tree-shaking (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Dec 27, 2024
1 parent 5a8c766 commit 44ed5b1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/rollup/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ export async function buildInputConfig(
return externals.some((name) => id === name || id.startsWith(name + '/'))
},
plugins,
treeshake: {
propertyReadSideEffects: false,
},
treeshake: 'recommended',
onwarn(warning, warn) {
const code = warning.code || ''
// Some may not have types, like CLI binary
Expand Down
7 changes: 7 additions & 0 deletions test/compile/treeshake/__snapshot__/treeshake.js.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Foo {
getFoo() {
return 'foo';
}
}

export { Foo };
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class o{getFoo(){return"foo"}}export{o as Foo};
14 changes: 14 additions & 0 deletions test/compile/treeshake/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Foo {
getFoo() {
return 'foo'
}
}

// This will be removed by treeshaking
class Bar {
getBar() {
return 'bar'
}
}

export { Foo }

0 comments on commit 44ed5b1

Please sign in to comment.