Index: lib/src/compiler/module_builder.dart |
diff --git a/lib/src/compiler/module_builder.dart b/lib/src/compiler/module_builder.dart |
index 7a6866c6463c53269bc03c0f817ff11c01b59a5a..0b2be9159c0d21123dffe4184d179ea5b4f44e84 100644 |
--- a/lib/src/compiler/module_builder.dart |
+++ b/lib/src/compiler/module_builder.dart |
@@ -104,7 +104,10 @@ class LegacyModuleBuilder extends _ModuleBuilder { |
/// Generates node modules. |
class NodeModuleBuilder extends _ModuleBuilder { |
Program build(Program module) { |
- var importStatements = [js.statement("'use strict';"),]; |
+ var importStatements = []; |
+ |
+ // Collect imports/exports/statements. |
+ visitProgram(module); |
for (var import in imports) { |
// TODO(jmesserly): we could use destructuring once Atom supports it. |
@@ -135,7 +138,13 @@ class NodeModuleBuilder extends _ModuleBuilder { |
} |
} |
} |
- return new Program(statements); |
+ |
+ // TODO(vsm): See https://github.com/dart-lang/dev_compiler/issues/512 |
+ // This extra level of indirection should be unnecessary. |
+ var block = |
+ js.statement("(function() { 'use strict'; #; })()", [statements]); |
+ |
+ return new Program([block]); |
} |
} |