Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1106)

Unified Diff: lib/src/compiler/module_builder.dart

Issue 1893293003: Fix for node modules (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Add TODO and regen Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/codegen/expect/language-all.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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]);
}
}
« no previous file with comments | « no previous file | test/codegen/expect/language-all.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698