diff --git a/CHANGELOG.md b/CHANGELOG.md index 54839e0afb..f505467079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Gaps between patch versions are faulty/broken releases. ## 2.2.0 * Make `system` module formatter modules anonymous by default. + * Fix duplicate comments being output, breaking code. ## 2.1.0 diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index dd839faa23..4745caedad 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -293,8 +293,9 @@ t.removeComments = function (child) { }; t.inheritsComments = function (child, parent) { - child.leadingComments = _.compact([].concat(child.leadingComments, parent.leadingComments)); - child.trailingComments = _.compact([].concat(child.trailingComments, parent.trailingComments)); + _.each(["leadingComments", "trailingComments"], function (key) { + child[key] = _.uniq(_.compact([].concat(child[key], parent[key]))); + }); return child; };