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

Side by Side Diff: pkg/dev_compiler/web/main.dart

Issue 2303163002: Update web_command code so that it continues to use the legacy module loader. Drive by removal of m… (Closed)
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 /// Command line entry point for Dart Development Compiler (dartdevc).
7 ///
8 /// Supported commands are
9 /// * compile: builds a collection of dart libraries into a single JS module
10 ///
11 /// Additionally, these commands are being considered
12 /// * link: combines several JS modules into a single JS file
13 /// * build: compiles & links a set of code, automatically determining
14 /// appropriate groupings of libraries to combine into JS modules
15 /// * watch: watch a directory and recompile build units automatically
16 /// * serve: uses `watch` to recompile and exposes a simple static file server
17 /// for local development
18 ///
19 /// These commands are combined so we have less names to expose on the PATH,
20 /// and for development simplicity while the precise UI has not been determined.
21 ///
22 /// A more typical structure for web tools is simply to have the compiler with
23 /// "watch" as an option. The challenge for us is:
24 ///
25 /// * Dart used to assume whole-program compiles, so we don't have a
26 /// user-declared unit of building, and neither "libraries" or "packages" will
27 /// work,
28 /// * We do not assume a `node` JS installation, so we cannot easily reuse
29 /// existing tools for the "link" step, or assume users have a local
30 /// file server,
31 /// * We didn't have a file watcher API at first,
32 /// * We had no conventions about where compiled output should go (or even
33 /// that we would be compiling at all, vs running on an in-browser Dart VM),
34 /// * We wanted a good first impression with our simple examples, so we used
35 /// local file servers, and users have an expectation of it now, even though
36 /// it doesn't scale to typical apps that need their own real servers.
37
38 @JS() 6 @JS()
39 library dev_compiler.web.main; 7 library dev_compiler.web.main;
40 8
41 import 'dart:async'; 9 import 'dart:async';
42 10
43 import 'package:args/command_runner.dart'; 11 import 'package:args/command_runner.dart';
44 import 'package:js/js.dart'; 12 import 'package:js/js.dart';
45 13
46 import 'web_command.dart'; 14 import 'web_command.dart';
47 15
48 @JS() 16 @JS(r'$setUpDartDevCompilerInBrowser')
49 external set setUpCompilerInBrowser(Function function); 17 external set setUpCompilerInBrowser(Function function);
50 18
51 Future main() async { 19 Future main() async {
52 var args = ['compile']; 20 var args = ['compile'];
53 _runCommand(args); 21 _runCommand(args);
54 } 22 }
55 23
56 /// Runs a single compile command, and returns an exit code. 24 /// Runs a single compile command, and returns an exit code.
57 Future<int> _runCommand(List<String> args, 25 Future<int> _runCommand(List<String> args,
58 {MessageHandler messageHandler}) async { 26 {MessageHandler messageHandler}) async {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 messageHandler(""); 69 messageHandler("");
102 messageHandler(" dartdevc arguments: " + args.join(' ')); 70 messageHandler(" dartdevc arguments: " + args.join(' '));
103 messageHandler(""); 71 messageHandler("");
104 messageHandler("```"); 72 messageHandler("```");
105 messageHandler(error); 73 messageHandler(error);
106 messageHandler(stackTrace); 74 messageHandler(stackTrace);
107 messageHandler("```"); 75 messageHandler("```");
108 return 70; 76 return 70;
109 } 77 }
110 } 78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698