whitespace in generated code and node modules fixes
diff --git a/lib/src/codegen/module_builder.dart b/lib/src/codegen/module_builder.dart
index 6e20cd3..2dba713 100644
--- a/lib/src/codegen/module_builder.dart
+++ b/lib/src/codegen/module_builder.dart
@@ -89,6 +89,7 @@
moduleStatements.addAll(_flattenBlocks(moduleItems));
if (_exports.isNotEmpty) {
+ moduleStatements.add(js.comment(''));
moduleStatements.add(js.comment('Exports:'));
// TODO(jmesserly): make these immutable in JS?
_exports.forEach((name, exportName) {
@@ -148,6 +149,7 @@
moduleStatements.addAll(_flattenBlocks(moduleItems));
if (_exports.isNotEmpty) {
+ moduleStatements.add(js.comment(''));
moduleStatements.add(js.comment('Exports:'));
// TODO(jmesserly): make these immutable in JS?
_exports.forEach((name, exportName) {
@@ -168,19 +170,22 @@
JS.Program build(String jsPath, String jsModuleValue,
JS.Identifier exportsVar, Iterable<JS.ModuleItem> moduleItems) {
var moduleStatements = <JS.ModuleItem>[js.statement("'use strict';"),];
+ moduleStatements.add(js.comment(''));
for (var i in _imports) {
+ var moduleName = js.string(_relativeModuleName(i.name, from: jsPath));
if (i.libVar == null) {
- moduleStatements.add(js.statement('require(#);', [js.string(i.name)]));
+ moduleStatements.add(js.statement('require(#);', [moduleName]));
} else {
moduleStatements.add(
- js.statement('let # = require(#);', [i.libVar, js.string(i.name)]));
+ js.statement('let # = require(#);', [i.libVar, moduleName]));
}
}
moduleStatements.addAll(_flattenBlocks(moduleItems));
if (_exports.isNotEmpty) {
+ moduleStatements.add(js.comment(''));
moduleStatements.add(js.comment('Exports:'));
_exports.forEach((name, exportName) {
moduleStatements
diff --git a/lib/src/codegen/side_effect_analysis.dart b/lib/src/codegen/side_effect_analysis.dart
index 3a51a46..08f5195 100644
--- a/lib/src/codegen/side_effect_analysis.dart
+++ b/lib/src/codegen/side_effect_analysis.dart
@@ -11,7 +11,7 @@
import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
import 'package:analyzer/src/generated/source.dart' show Source;
-/// True is the expression can be evaluated multiple times without causing
+/// True if the expression can be evaluated multiple times without causing
/// code execution. This is true for final fields. This can be true for local
/// variables, if:
/// * they are not assigned within the [context].
diff --git a/lib/src/compiler.dart b/lib/src/compiler.dart
index 8e8d7b3..9eecf37 100644
--- a/lib/src/compiler.dart
+++ b/lib/src/compiler.dart
@@ -91,7 +91,7 @@
_inputBaseDir = options.inputBaseDir;
if (outputDir != null) {
_jsGen = new JSGenerator(this);
- _runtimeOutputDir = path.join(outputDir, 'dev_compiler', 'runtime');
+ _runtimeOutputDir = outputDir;
}
_dartCore = context.typeProvider.objectType.element.library;
}
diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart
index 955f6d9..4fb500b 100644
--- a/lib/src/js/printer.dart
+++ b/lib/src/js/printer.dart
@@ -570,6 +570,7 @@
}
visitFunctionDeclaration(FunctionDeclaration declaration) {
+ lineOut();
indent();
outClosureAnnotation(declaration);
functionOut(declaration.function, declaration.name);
@@ -1088,6 +1089,7 @@
}
visitClassDeclaration(ClassDeclaration node) {
+ lineOut();
indent();
visit(node.classExpr);
lineOut();
@@ -1332,12 +1334,15 @@
void visitComment(Comment node) {
if (shouldCompressOutput) return;
String comment = node.comment.trim();
- if (comment.isEmpty) return;
- for (var line in comment.split('\n')) {
- if (comment.startsWith('//')) {
- outIndentLn(line.trim());
- } else {
- outIndentLn('// ${line.trim()}');
+ if (comment.isEmpty) {
+ lineOut();
+ } else {
+ for (var line in comment.split('\n')) {
+ if (comment.startsWith('//')) {
+ outIndentLn(line.trim());
+ } else {
+ outIndentLn('// ${line.trim()}');
+ }
}
}
}
diff --git a/test/codegen_test.dart b/test/codegen_test.dart
index 01f5359..402b14b 100644
--- a/test/codegen_test.dart
+++ b/test/codegen_test.dart
@@ -222,8 +222,7 @@
});
}
- var expectedRuntime =
- defaultRuntimeFiles.map((f) => 'dev_compiler/runtime/$f');
+ var expectedRuntime = defaultRuntimeFiles.map((f) => f);
test('devc jscodegen sunflower.html', () {
var filePath = path.join(inputDir, 'sunflower', 'sunflower.html');