diff --git a/lib/minify.js b/lib/minify.js index fdc48961..73f0e456 100644 --- a/lib/minify.js +++ b/lib/minify.js @@ -77,7 +77,7 @@ function minify(files, options) { set_shorthand("ie8", options, [ "compress", "mangle", "output" ]); set_shorthand("keep_classnames", options, [ "compress", "mangle" ]); set_shorthand("keep_fnames", options, [ "compress", "mangle" ]); - set_shorthand("module", options, [ "compress" ]); + set_shorthand("module", options, [ "compress", "mangle" ]); set_shorthand("safari10", options, [ "mangle", "output" ]); set_shorthand("toplevel", options, [ "compress", "mangle" ]); set_shorthand("warnings", options, [ "compress" ]); diff --git a/lib/scope.js b/lib/scope.js index 09687aaf..de572f3e 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -110,7 +110,11 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ // pass 1: setup scope chaining and handle definitions var self = this; - var scope = self.parent_scope = null; + var scope = null; + if (options.module) { + scope = new AST_Scope(self); + } + self.parent_scope = scope; var labels = new Dictionary(); var defun = null; var in_destructuring = null; diff --git a/test/compress/harmony.js b/test/compress/harmony.js index 7d2fdb93..c0eaab44 100644 --- a/test/compress/harmony.js +++ b/test/compress/harmony.js @@ -1617,3 +1617,15 @@ module_enables_strict_mode: { } } } + +module_mangle_scope: { + mangle = { + module: true + } + input: { + let a = 10; + } + expect: { + let e = 10; + } +}