Index: sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart b/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart |
index dd90b9f688a947de75b58271af16c86126708d41..1665be9d538da3d3c4db8d5e71e1673dfe779d42 100644 |
--- a/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart |
+++ b/sdk/lib/_internal/pub/lib/src/barback/pub_package_provider.dart |
@@ -9,8 +9,9 @@ import 'dart:async'; |
import 'package:barback/barback.dart'; |
import 'package:path/path.dart' as path; |
-import '../package_graph.dart'; |
import '../io.dart'; |
+import '../package_graph.dart'; |
+import '../sdk.dart' as sdk; |
/// An implementation of barback's [PackageProvider] interface so that barback |
/// can find assets within pub packages. |
@@ -20,22 +21,38 @@ class PubPackageProvider implements PackageProvider { |
PubPackageProvider(PackageGraph graph) |
: _graph = graph, |
- packages = new List.from(graph.packages.keys)..add(r"$pub"); |
+ packages = [r"$pub", r"$sdk"]..addAll(graph.packages.keys); |
Future<Asset> getAsset(AssetId id) { |
- if (id.package != r'$pub') { |
- var nativePath = path.fromUri(id.path); |
- var file = path.join(_graph.packages[id.package].dir, nativePath); |
+ // "$pub" is a psuedo-package that allows pub's transformer-loading |
+ // infrastructure to share code with pub proper. |
+ if (id.package == r'$pub') { |
+ var components = path.url.split(id.path); |
+ assert(components.isNotEmpty); |
+ assert(components.first == 'lib'); |
+ components[0] = 'dart'; |
+ var file = assetPath(path.joinAll(components)); |
return new Future.value(new Asset.fromPath(id, file)); |
} |
- // "$pub" is a psuedo-package that allows pub's transformer-loading |
- // infrastructure to share code with pub proper. |
- var components = path.url.split(id.path); |
- assert(components.isNotEmpty); |
- assert(components.first == 'lib'); |
- components[0] = 'dart'; |
- var file = assetPath(path.joinAll(components)); |
+ // "$sdk" is a pseudo-package that provides access to the Dart library |
+ // sources in the SDK. The dart2js transformer uses this to locate the Dart |
+ // sources for "dart:" libraries. |
+ if (id.package == r'$sdk') { |
+ // The asset path contains two "lib" entries. The first represent's pub's |
+ // concept that all public assets are in "lib". The second comes from the |
+ // organization of the SDK itself. Strip off the first. Leave the second |
+ // since dart2js adds it and expects it to be there. |
+ var parts = path.split(path.fromUri(id.path)); |
+ assert(parts.isNotEmpty && parts[0] == 'lib'); |
+ parts = parts.skip(1); |
+ |
+ var file = path.join(sdk.rootDirectory, path.joinAll(parts)); |
+ return new Future.value(new Asset.fromPath(id, file)); |
+ } |
+ |
+ var nativePath = path.fromUri(id.path); |
+ var file = path.join(_graph.packages[id.package].dir, nativePath); |
return new Future.value(new Asset.fromPath(id, file)); |
} |
} |