support export statements properly (#2126)

- mangle & compress correctly with `toplevel`
- retain non-toplevel import/export
- parse & output `export { variable as name }`
- remove extraneous spaces from `beautify`


fixes #2038
fixes #2124
This commit is contained in:
Alex Lam S.L
2017-06-21 00:51:36 +08:00
committed by GitHub
parent 849ba79dee
commit 62d1fbf645
7 changed files with 199 additions and 57 deletions

View File

@@ -243,9 +243,22 @@ TreeTransformer.prototype = new TreeWalker;
self.expression = self.expression.transform(tw);
});
_(AST_Export, function(self, tw){
_(AST_NameMapping, function(self, tw) {
self.foreign_name = self.foreign_name.transform(tw);
self.name = self.name.transform(tw);
});
_(AST_Import, function(self, tw) {
if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
if (self.imported_names) do_list(self.imported_names, tw);
self.module_name = self.module_name.transform(tw);
});
_(AST_Export, function(self, tw) {
if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
if (self.exported_names) do_list(self.exported_names, tw);
if (self.module_name) self.module_name = self.module_name.transform(tw);
});
_(AST_TemplateString, function(self, tw) {