Chromium Code Reviews| Index: sdk/lib/_internal/pub/lib/src/command/serve.dart |
| diff --git a/sdk/lib/_internal/pub/lib/src/command/serve.dart b/sdk/lib/_internal/pub/lib/src/command/serve.dart |
| index 3a46f5ca398afda8dfb4c4cd149bd0aa4d86d747..32f0447419fddcae34432139feaec86052ebee2f 100644 |
| --- a/sdk/lib/_internal/pub/lib/src/command/serve.dart |
| +++ b/sdk/lib/_internal/pub/lib/src/command/serve.dart |
| @@ -6,8 +6,10 @@ library pub.command.serve; |
| import 'dart:async'; |
| -import '../barback.dart' as barback; |
| +import '../barback/dart_forwarding_transformer.dart'; |
| +import '../barback/dart2js_transformer.dart'; |
| import '../barback/pub_package_provider.dart'; |
| +import '../barback.dart' as barback; |
| import '../command.dart'; |
| import '../entrypoint.dart'; |
| import '../exit_codes.dart' as exit_codes; |
| @@ -29,6 +31,9 @@ class ServeCommand extends PubCommand { |
| String get hostname => commandOptions['hostname']; |
| + /// `true` if Dart entrypoints should be compiled to JavaScript. |
| + bool get useDart2js => commandOptions['dart2js']; |
|
nweiz
2013/10/04 20:26:10
I think this should be capitalized "useDart2JS". T
Bob Nystrom
2013/10/04 23:23:59
Done.
|
| + |
| ServeCommand() { |
| commandParser.addOption('port', defaultsTo: '8080', |
| help: 'The port to listen on.'); |
| @@ -40,6 +45,9 @@ class ServeCommand extends PubCommand { |
| commandParser.addOption('hostname', |
| defaultsTo: 'localhost', |
| hide: true); |
| + |
| + commandParser.addFlag('dart2js', defaultsTo: true, |
| + help: 'Compile Dart to JavaScript.'); |
| } |
| Future onRun() { |
| @@ -52,10 +60,21 @@ class ServeCommand extends PubCommand { |
| return flushThenExit(exit_codes.USAGE); |
| } |
| - return ensureLockFileIsUpToDate() |
| - .then((_) => entrypoint.loadPackageGraph()) |
| - .then((graph) => barback.createServer(hostname, port, graph)) |
| - .then((server) { |
| + return ensureLockFileIsUpToDate().then((_) { |
| + return entrypoint.loadPackageGraph(); |
| + }).then((graph) { |
| + // TODO(rnystrom): Add support for dart2dart transformer here. |
| + var builtInTransformers = null; |
| + if (useDart2js) { |
| + builtInTransformers = [ |
| + new Dart2JSTransformer(graph), |
| + new DartForwardingTransformer() |
| + ]; |
| + } |
| + |
| + return barback.createServer(hostname, port, graph, |
| + builtInTransformers: builtInTransformers); |
| + }).then((server) { |
| /// This completer is used to keep pub running (by not completing) and |
| /// to pipe fatal errors to pub's top-level error-handling machinery. |
| var completer = new Completer(); |