Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: sdk/lib/_internal/pub/lib/src/barback.dart

Issue 24016002: Support transformers that depend on other transformers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/barback.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback.dart b/sdk/lib/_internal/pub/lib/src/barback.dart
index 36de8dc664bb995f2ed200a8014b59ab597085e8..372aaa92c099c58a281ccbb31695e8dc0274533c 100644
--- a/sdk/lib/_internal/pub/lib/src/barback.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback.dart
@@ -8,7 +8,7 @@ import 'dart:async';
import 'package:barback/barback.dart';
-import 'barback/load_transformers.dart';
+import 'barback/load_all_transformers.dart';
import 'barback/pub_package_provider.dart';
import 'barback/rewrite_import_transformer.dart';
import 'barback/server.dart';
@@ -44,7 +44,7 @@ Future<BarbackServer> createServer(String host, int port, PackageGraph graph) {
})
];
- _loadTransformers(server, graph).then((_) {
+ loadAllTransformers(server, graph).then((_) {
if (!completer.isCompleted) completer.complete(server);
}).catchError((error) {
if (!completer.isCompleted) completer.completeError(error);
@@ -57,50 +57,3 @@ Future<BarbackServer> createServer(String host, int port, PackageGraph graph) {
});
});
}
-
-/// Loads all transformers depended on by packages in [graph].
-///
-/// This uses [server] to serve the Dart files from which transformers are
-/// loaded, then adds the transformers to `server.barback`.
-Future _loadTransformers(BarbackServer server, PackageGraph graph) {
- // Add a rewrite transformer for each package, so that we can resolve
- // "package:" imports while loading transformers.
- var rewrite = new RewriteImportTransformer();
- for (var package in graph.packages.values) {
- server.barback.updateTransformers(package.name, [[rewrite]]);
- }
-
- // A map from each transformer id to the set of packages that use it.
- var idsToPackages = new Map<AssetId, Set<String>>();
- for (var package in graph.packages.values) {
- for (var id in unionAll(package.pubspec.transformers)) {
- idsToPackages.putIfAbsent(id, () => new Set<String>()).add(package.name);
- }
- }
-
- // TODO(nweiz): support transformers that (possibly transitively)
- // depend on other transformers.
- var transformersForId = new Map<AssetId, Set<Transformer>>();
- return Future.wait(idsToPackages.keys.map((id) {
- return loadTransformers(server, id).then((transformers) {
- if (transformers.isEmpty) {
- var path = id.path.replaceFirst('lib/', '');
- // Ensure that packages are listed in a deterministic order.
- var packages = idsToPackages[id].toList();
- packages.sort();
- throw new ApplicationException(
- "No transformers were defined in package:${id.package}/$path,\n"
- "required by ${packages.join(', ')}.");
- }
-
- transformersForId[id] = transformers;
- });
- })).then((_) {
- for (var package in graph.packages.values) {
- var phases = package.pubspec.transformers.map((phase) {
- return unionAll(phase.map((id) => transformersForId[id]));
- });
- server.barback.updateTransformers(package.name, phases);
- }
- });
-}

Powered by Google App Engine
This is Rietveld 408576698