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 9e1d7b43c48d532585b95a56dc1c59416705af38..7740ba60f450c4c165ecdc4880b04a984a2f27bc 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 |
@@ -10,18 +10,32 @@ import 'package:barback/barback.dart'; |
import 'package:path/path.dart' as path; |
import '../package_graph.dart'; |
+import '../io.dart'; |
/// An implementation of barback's [PackageProvider] interface so that barback |
/// can find assets within pub packages. |
class PubPackageProvider implements PackageProvider { |
final PackageGraph _graph; |
+ final List<String> packages; |
- PubPackageProvider(this._graph); |
- |
- Iterable<String> get packages => _graph.packages.keys; |
+ PubPackageProvider(PackageGraph graph) |
+ : _graph = graph, |
+ packages = new List.from(graph.packages.keys)..add(r"$pub"); |
Future<Asset> getAsset(AssetId id) { |
- var file = path.join(_graph.packages[id.package].dir, id.path); |
+ if (id.package != r'$pub') { |
+ var nativePath = path.joinAll(path.url.split(id.path)); |
+ var file = path.join(_graph.packages[id.package].dir, nativePath); |
+ 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)); |
return new Future.value(new Asset.fromPath(id, file)); |
} |
} |