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

Unified Diff: sdk/lib/_internal/pub/lib/src/command/build.dart

Issue 69043003: Allow user to specify mode for pub build/serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Get rid of "--minify" flags. Created 7 years, 1 month 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/command/build.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/build.dart b/sdk/lib/_internal/pub/lib/src/command/build.dart
index 4cacb6d310069c49ee5b068e0a2eff7abf3ef10f..2df2ecf18a1e6bf7530563538a1cb7c2750ebc1e 100644
--- a/sdk/lib/_internal/pub/lib/src/command/build.dart
+++ b/sdk/lib/_internal/pub/lib/src/command/build.dart
@@ -10,6 +10,7 @@ import 'package:barback/barback.dart';
import 'package:path/path.dart' as path;
import '../barback/dart2js_transformer.dart';
+import '../barback/dart_forwarding_transformer.dart';
import '../barback.dart' as barback;
import '../command.dart';
import '../exit_codes.dart' as exit_codes;
@@ -33,12 +34,12 @@ class BuildCommand extends PubCommand {
/// The path to the application's build output directory.
String get target => path.join(entrypoint.root.dir, 'build');
- /// `true` if generated JavaScript should be minified.
- bool get minify => commandOptions['minify'];
+ /// The build mode.
+ BarbackMode get mode => new BarbackMode(commandOptions['mode']);
BuildCommand() {
- commandParser.addFlag('minify', defaultsTo: true,
- help: 'Minify generated JavaScript.');
+ commandParser.addOption('mode', defaultsTo: BarbackMode.RELEASE.toString(),
+ help: 'Mode to run transformers in.');
}
Future onRun() {
@@ -53,14 +54,18 @@ class BuildCommand extends PubCommand {
return entrypoint.ensureLockFileIsUpToDate().then((_) {
return entrypoint.loadPackageGraph();
}).then((graph) {
- dart2jsTransformer = new Dart2JSTransformer(graph, minify: minify);
+ dart2jsTransformer = new Dart2JSTransformer(graph, mode);
+ var builtInTransformers = [
+ dart2jsTransformer,
+ new DartForwardingTransformer(mode)
+ ];
// Since this server will only be hit by the transformer loader and isn't
// user-facing, just use an IPv4 address to avoid a weird bug on the
// OS X buildbots.
// TODO(rnystrom): Allow specifying mode.
- return barback.createServer("127.0.0.1", 0, graph, BarbackMode.RELEASE,
- builtInTransformers: [dart2jsTransformer],
+ return barback.createServer("127.0.0.1", 0, graph, mode,
+ builtInTransformers: builtInTransformers,
watcher: barback.WatcherType.NONE);
}).then((server) {
// Show in-progress errors, but not results. Those get handled implicitly
@@ -72,10 +77,6 @@ class BuildCommand extends PubCommand {
return log.progress("Building ${entrypoint.root.name}",
() => server.barback.getAllAssets());
}).then((assets) {
- // Don't copy Dart libraries. Their contents will already be included
- // in the generated JavaScript.
- assets = assets.where((asset) => asset.id.extension != ".dart");
-
return Future.wait(assets.map((asset) {
// Figure out the output directory for the asset, which is the same
// as the path pub serve would use to serve it.

Powered by Google App Engine
This is Rietveld 408576698