| Index: lib/src/codegen/js_codegen.dart
|
| diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
|
| index 628d7a1e95a80bb5c7a80475896653929a4c6611..1c221629cb166a0fb91048f69d92521a4cf08e59 100644
|
| --- a/lib/src/codegen/js_codegen.dart
|
| +++ b/lib/src/codegen/js_codegen.dart
|
| @@ -1289,7 +1289,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
|
| }
|
|
|
| @override
|
| - visitRethrowExpression(RethrowExpression node){
|
| + visitRethrowExpression(RethrowExpression node) {
|
| if (node.parent is ExpressionStatement) {
|
| return js.statement('throw #;', _catchParameter);
|
| } else {
|
| @@ -1747,7 +1747,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) {
|
| @@ -1789,11 +1789,23 @@ 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 == 'file') {
|
| + filepath = path.relative(filepath, from: path.dirname(root.path));
|
| + } else {
|
| + assert(uri.scheme == 'package');
|
| + // filepath is good here, we want the output to start with a directory
|
| + // matching the package name.
|
| + }
|
| + return filepath;
|
| +}
|
|
|
| class SourceMapPrintingContext extends JS.JavaScriptPrintingContext {
|
| final srcmaps.Printer printer;
|
|
|