diff --git a/lib/scope.js b/lib/scope.js index 572f7d322..630ee9b1a 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -781,6 +781,8 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { } const mangled_names = this.mangled_names = new Set(); + unmangleable_names = new Set(); + if (options.cache) { this.globals.forEach(collect); if (options.cache.props) { @@ -833,7 +835,6 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { this.walk(tw); if (options.keep_fnames || options.keep_classnames) { - unmangleable_names = new Set(); // Collect a set of short names which are unmangleable, // for use in avoiding collisions in next_mangled. to_mangle.forEach(def => { @@ -849,9 +850,9 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options) { unmangleable_names = null; function collect(symbol) { - const should_mangle = !options.reserved.has(symbol.name) - && !(symbol.export & MASK_EXPORT_DONT_MANGLE); - if (should_mangle) { + if (symbol.export & MASK_EXPORT_DONT_MANGLE) { + unmangleable_names.add(symbol.name); + } else if (!options.reserved.has(symbol.name)) { to_mangle.push(symbol); } } diff --git a/test/compress/export.js b/test/compress/export.js index 417989ada..17b8e03e3 100644 --- a/test/compress/export.js +++ b/test/compress/export.js @@ -921,3 +921,34 @@ issue_333_toplevel: { export { _setToString }; } } + +export_object_property_mangle: { + module = true + options = { + reduce_vars: false, + } + mangle = true + input: { + const n = null; + export const o = { o: n }; + } + expect: { + const n = null; + export const o = {o: n}; + } +} + +export_object_property_mangle_2: { + module = true + mangle = true + input: { + const n = null; + const o = { o: n }; + export { o }; + } + expect: { + const o = null; + const n = {o: o}; + export {n as o}; + } +}