Index: lib/src/compiler/code_generator.dart |
diff --git a/lib/src/compiler/code_generator.dart b/lib/src/compiler/code_generator.dart |
index 2c19b39ef6f2c7ac0a9af6e10978145d953ec503..608a896307951c205cf6f07e01168d5dd0b8212c 100644 |
--- a/lib/src/compiler/code_generator.dart |
+++ b/lib/src/compiler/code_generator.dart |
@@ -3761,6 +3761,17 @@ class CodeGenerator extends GeneralizingAstVisitor |
/// This never uses the library's name (the identifier in the `library` |
/// declaration) as it doesn't have any meaningful rules enforced. |
String jsLibraryName(LibraryElement library) { |
+ var uri = library.source.uri; |
+ if (uri.scheme == 'package') { |
+ // Strip the package name. |
+ // TODO(vsm): This is not unique if an escaped '/'appears in a filename. |
+ // E.g., "foo/bar.dart" and "foo$47bar.dart" would collide. |
+ var packageRelativePath = uri.pathSegments.skip(1).join('/'); |
Jennifer Messerly
2016/04/26 22:59:33
Yeah in general it's not going to be unique.
Also
|
+ return pathToJSIdentifier(packageRelativePath); |
+ } |
+ // TODO(vsm): This is not unique, but we're not in |
+ // a package. We need a mechanism for creating a unique library |
+ // name. |
return pathToJSIdentifier(library.source.uri.pathSegments.last); |
} |