Chromium Code Reviews| Index: lib/src/codegen/js_codegen.dart |
| diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart |
| index 1f69fefc77ace646444ca3f6ddc6c8f4f11fbdbb..839c6fe8335417dc3f6718f1eebd44a65ee62c7f 100644 |
| --- a/lib/src/codegen/js_codegen.dart |
| +++ b/lib/src/codegen/js_codegen.dart |
| @@ -1716,7 +1716,7 @@ class JSGenerator extends CodeGenerator { |
| JS.Block jsTree = |
| new JSCodegenVisitor(info, rules).generateLibrary(units, reporter); |
| - var outputPath = path.join(outDir, jsOutputPath(info)); |
| + var outputPath = path.join(outDir, jsOutputPath(info, root)); |
| new Directory(path.dirname(outputPath)).createSync(recursive: true); |
| if (options.emitSourceMaps) { |
| @@ -1758,11 +1758,21 @@ String debugJsNodeToString(JS.Node node) { |
| /// declaration) as it doesn't have any meaningful rules enforced. |
| String jsLibraryName(LibraryElement library) => canonicalLibraryName(library); |
| -/// Path to file that will be generated for [info]. |
| -// TODO(jmesserly): library directory should be relative to its package |
| -// root. For example, "package:dev_compiler/src/codegen/js_codegen.dart" would be: |
| -// "ddc/src/codegen/js_codegen.js" under the output directory. |
| -String jsOutputPath(LibraryInfo info) => '${info.name}/${info.name}.js'; |
| +/// Path to file that will be generated for [info]. In case it's url is a |
| +/// `file:` url, we use [root] to determine the relative path from the entry |
| +/// point file. |
| +String jsOutputPath(LibraryInfo info, Uri root) { |
| + var uri = info.library.source.uri; |
| + var filepath = '${path.withoutExtension(uri.path)}.js'; |
| + if (uri.scheme == 'dart') { |
| + filepath = 'dart/$filepath'; |
| + } else if (uri.scheme == 'package') { |
| + filepath = 'packages/$filepath'; |
|
Jennifer Messerly
2015/03/02 18:40:51
hmmm. I wonder about this. Does it make sense in a
Siggi Cherem (dart-lang)
2015/03/02 18:57:29
Good point - this also brings a related question a
Siggi Cherem (dart-lang)
2015/03/03 02:09:03
Done. I updated the CL to match Option A.
|
| + } else if (uri.scheme == 'file') { |
| + filepath = path.relative(filepath, from: path.dirname(root.path)); |
| + } |
| + return filepath; |
| +} |
| class SourceMapPrintingContext extends JS.JavaScriptPrintingContext { |
| final srcmaps.Printer printer; |