Skip to content

Commit

Permalink
fix(dce): don't remove toplevel classes (#753)
Browse files Browse the repository at this point in the history
Apply the same trick we use in mangler to detect toplevel classes
  • Loading branch information
boopathi authored Dec 10, 2017
1 parent 9a74dfd commit 37064b4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class Foo {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class Foo {}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ module.exports = ({ types: t, traverse }) => {
) {
// `bar(function foo() {})` foo is not referenced but it's used.
continue;
} else if (
// ClassDeclaration has binding in two scopes
// 1. The scope in which it is declared
// 2. The class's own scope
binding.path.isClassDeclaration() &&
binding.path === scope.path
) {
continue;
}

const mutations = [];
Expand Down

0 comments on commit 37064b4

Please sign in to comment.