| Index: sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
|
| diff --git a/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart b/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
|
| index c07d8600244d3ae048ae7aa933d5e6ceea805b75..bfd97b35aff834ff353ff2fe77ff0d46f067d7b0 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
|
| +++ b/sdk/lib/_internal/pub/lib/src/barback/asset_environment.dart
|
| @@ -18,7 +18,6 @@ import '../io.dart';
|
| import '../log.dart' as log;
|
| import '../package.dart';
|
| import '../package_graph.dart';
|
| -import '../sdk.dart' as sdk;
|
| import '../source/cached.dart';
|
| import '../utils.dart';
|
| import 'admin_server.dart';
|
| @@ -60,15 +59,19 @@ class AssetEnvironment {
|
| /// entrypoints are loaded. Each entrypoint is expected to refer to a Dart
|
| /// library.
|
| ///
|
| + /// If [environmentConstants] is passed, the constants it defines are passed
|
| + /// on to the built-in dart2js transformer.
|
| + ///
|
| /// Returns a [Future] that completes to the environment once the inputs,
|
| /// transformers, and server are loaded and ready.
|
| static Future<AssetEnvironment> create(Entrypoint entrypoint,
|
| BarbackMode mode, {WatcherType watcherType, String hostname, int basePort,
|
| Iterable<String> packages, Iterable<AssetId> entrypoints,
|
| - bool useDart2JS: true}) {
|
| + Map<String, String> environmentConstants, bool useDart2JS: true}) {
|
| if (watcherType == null) watcherType = WatcherType.NONE;
|
| if (hostname == null) hostname = "localhost";
|
| if (basePort == null) basePort = 0;
|
| + if (environmentConstants == null) environmentConstants = {};
|
|
|
| return log.progress("Loading asset environment", () async {
|
| var graph = await entrypoint.loadPackageGraph();
|
| @@ -77,7 +80,7 @@ class AssetEnvironment {
|
| barback.log.listen(_log);
|
|
|
| var environment = new AssetEnvironment._(graph, barback, mode,
|
| - watcherType, hostname, basePort);
|
| + watcherType, hostname, basePort, environmentConstants);
|
|
|
| await environment._load(entrypoints: entrypoints, useDart2JS: useDart2JS);
|
| return environment;
|
| @@ -125,6 +128,9 @@ class AssetEnvironment {
|
| /// The mode to run the transformers in.
|
| final BarbackMode mode;
|
|
|
| + /// Constants to passed to the built-in dart2js transformer.
|
| + final Map<String, String> environmentConstants;
|
| +
|
| /// The [Transformer]s that should be appended by default to the root
|
| /// package's transformer cascade. Will be empty if there are none.
|
| final _builtInTransformers = <Transformer>[];
|
| @@ -158,7 +164,8 @@ class AssetEnvironment {
|
| Set<AssetId> _modifiedSources;
|
|
|
| AssetEnvironment._(this.graph, this.barback, this.mode,
|
| - this._watcherType, this._hostname, this._basePort);
|
| + this._watcherType, this._hostname, this._basePort,
|
| + this.environmentConstants);
|
|
|
| /// Gets the built-in [Transformer]s that should be added to [package].
|
| ///
|
| @@ -268,7 +275,6 @@ class AssetEnvironment {
|
| log.fine("Executables for $packageName: $executableIds");
|
| if (executableIds.isEmpty) return {};
|
|
|
| - var package = graph.packages[packageName];
|
| var server = await servePackageBinDirectory(packageName);
|
| try {
|
| var precompiled = {};
|
| @@ -469,7 +475,7 @@ class AssetEnvironment {
|
| if (!containsDart2JS && useDart2JS) {
|
| _builtInTransformers.addAll([
|
| new Dart2JSTransformer(this, mode),
|
| - new DartForwardingTransformer(mode)
|
| + new DartForwardingTransformer()
|
| ]);
|
| }
|
|
|
|
|