Chromium Code Reviews| Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart |
| diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart |
| index 98afa9f74fd645b5b9c08106d0d5abc876b4b053..4d492fe622d32b0de3ea9d5488214a323c50d16d 100644 |
| --- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart |
| +++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart |
| @@ -517,35 +517,28 @@ class CodeGenerator extends GeneralizingAstVisitor |
| // modules we import, so we will never go down this code path for them. |
| _moduleItems |
| .add(js.statement('#.# = #;', [libraryName, name.selector, name])); |
| - } else { |
| - // top-level fields, getters, setters need to copy the property |
|
vsm
2016/11/15 15:13:21
Any reason to delete this? I think we hit this pa
|
| - // descriptor. |
| - _moduleItems.add(_callHelperStatement( |
| - 'export(#, #, #);', [libraryName, name.receiver, name.selector])); |
| } |
| } |
| - for (var export in exportedNames.definedNames.values) { |
| - if (export is PropertyAccessorElement) { |
| - export = (export as PropertyAccessorElement).variable; |
| - } |
| + // We only need to export main as it is the only method party of the |
|
vsm
2016/11/15 15:37:10
How about restoring the old code with just an opti
|
| + // publically exposed JS API for a library. |
| + var export = exportedNames.get('main'); |
| - // Don't allow redefining names from this library. |
| - if (currentNames.containsKey(export.name)) continue; |
| + if (export == null) return; |
| + if (export is PropertyAccessorElement) { |
| + export = (export as PropertyAccessorElement).variable; |
| + } |
| - if (export.isSynthetic && export is PropertyInducingElement) { |
| - _emitDeclaration(export.getter); |
| - _emitDeclaration(export.setter); |
| - } else { |
| - _emitDeclaration(export); |
| - } |
| - if (export is ClassElement && export.typeParameters.isNotEmpty) { |
| - // Export the generic name as well. |
| - // TODO(jmesserly): revisit generic classes |
| - emitExport(export, suffix: r'$'); |
| - } |
| - emitExport(export); |
| + // Don't allow redefining names from this library. |
| + if (currentNames.containsKey(export.name)) return; |
| + |
| + if (export.isSynthetic && export is PropertyInducingElement) { |
| + _emitDeclaration(export.getter); |
| + _emitDeclaration(export.setter); |
| + } else { |
| + _emitDeclaration(export); |
| } |
| + emitExport(export); |
| } |
| @override |