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

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

Issue 26027002: Add flag to pub serve to disable dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 2 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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback.dart ('k') | sdk/lib/_internal/pub/test/serve/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bc6f0188f06c193902b53fb82c0e58f04375a8fb 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'];
+
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();
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback.dart ('k') | sdk/lib/_internal/pub/test/serve/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698