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

Side by Side Diff: lib/src/options.dart

Issue 1458243002: implement ES6 modules in JS AST. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 unified diff | Download patch
« lib/src/js/nodes.dart ('K') | « lib/src/js/template.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Set of flags and options passed to the compiler 5 /// Set of flags and options passed to the compiler
6 library dev_compiler.src.options; 6 library dev_compiler.src.options;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 /// Output directory for generated code. 66 /// Output directory for generated code.
67 final String outputDir; 67 final String outputDir;
68 68
69 /// Emit Closure Compiler-friendly code. 69 /// Emit Closure Compiler-friendly code.
70 final bool closure; 70 final bool closure;
71 71
72 /// Whether to emit a workaround for missing arrow function bind-this in 72 /// Whether to emit a workaround for missing arrow function bind-this in
73 /// other V8 builds 73 /// other V8 builds
74 final bool arrowFnBindThisWorkaround; 74 final bool arrowFnBindThisWorkaround;
75 75
76 /// Which module format to support.
77 /// Currently 'es6' and 'dart' are supported.
78 final String moduleFormat;
79
76 const CodegenOptions( 80 const CodegenOptions(
77 {this.emitSourceMaps: true, 81 {this.emitSourceMaps: true,
78 this.forceCompile: false, 82 this.forceCompile: false,
79 this.closure: _CLOSURE_DEFAULT, 83 this.closure: _CLOSURE_DEFAULT,
80 this.outputDir, 84 this.outputDir,
81 this.arrowFnBindThisWorkaround: false}); 85 this.arrowFnBindThisWorkaround: false,
86 this.moduleFormat: 'dart'});
82 } 87 }
83 88
84 /// Options for devrun. 89 /// Options for devrun.
85 class RunnerOptions { 90 class RunnerOptions {
86 /// V8-based binary to be used to run the .js output (d8, iojs, node). 91 /// V8-based binary to be used to run the .js output (d8, iojs, node).
87 /// Can be just the executable name if it's in the path, or a path to the 92 /// Can be just the executable name if it's in the path, or a path to the
88 /// executable. 93 /// executable.
89 final String v8Binary; 94 final String v8Binary;
90 95
91 const RunnerOptions({this.v8Binary: _V8_BINARY_DEFAULT}); 96 const RunnerOptions({this.v8Binary: _V8_BINARY_DEFAULT});
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 225 }
221 226
222 if (serverMode && args.rest.length != 1) showUsage = true; 227 if (serverMode && args.rest.length != 1) showUsage = true;
223 228
224 return new CompilerOptions( 229 return new CompilerOptions(
225 codegenOptions: new CodegenOptions( 230 codegenOptions: new CodegenOptions(
226 emitSourceMaps: args['source-maps'], 231 emitSourceMaps: args['source-maps'],
227 forceCompile: args['force-compile'] || serverMode, 232 forceCompile: args['force-compile'] || serverMode,
228 closure: args['closure'], 233 closure: args['closure'],
229 outputDir: outputDir, 234 outputDir: outputDir,
230 arrowFnBindThisWorkaround: args['arrow-fn-bind-this']), 235 arrowFnBindThisWorkaround: args['arrow-fn-bind-this'],
236 moduleFormat: args['modules']),
231 sourceOptions: new SourceResolverOptions( 237 sourceOptions: new SourceResolverOptions(
232 useMockSdk: args['mock-sdk'], 238 useMockSdk: args['mock-sdk'],
233 dartSdkPath: sdkPath, 239 dartSdkPath: sdkPath,
234 useImplicitHtml: serverMode && 240 useImplicitHtml: serverMode &&
235 args.rest.length == 1 && 241 args.rest.length == 1 &&
236 args.rest[0].endsWith('.dart'), 242 args.rest[0].endsWith('.dart'),
237 customUrlMappings: customUrlMappings, 243 customUrlMappings: customUrlMappings,
238 useMultiPackage: args['use-multi-package'], 244 useMultiPackage: args['use-multi-package'],
239 packageRoot: args['package-root'], 245 packageRoot: args['package-root'],
240 packagePaths: args['package-paths'].split(','), 246 packagePaths: args['package-paths'].split(','),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 'look for packages in.', 291 'look for packages in.',
286 defaultsTo: '') 292 defaultsTo: '')
287 ..addOption('resources', 293 ..addOption('resources',
288 help: 'Additional resources to serve', defaultsTo: '') 294 help: 'Additional resources to serve', defaultsTo: '')
289 ..addFlag('source-maps', 295 ..addFlag('source-maps',
290 help: 'Whether to emit source map files', defaultsTo: true) 296 help: 'Whether to emit source map files', defaultsTo: true)
291 ..addOption('runtime-dir', 297 ..addOption('runtime-dir',
292 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null) 298 help: 'Where to find dev_compiler\'s runtime files', defaultsTo: null)
293 ..addFlag('arrow-fn-bind-this', 299 ..addFlag('arrow-fn-bind-this',
294 help: 'Work around `this` binding in => functions') 300 help: 'Work around `this` binding in => functions')
301 ..addOption('modules',
302 help: 'Which module pattern to emit',
303 allowed: ['es6', 'dart'],
304 allowedHelp: {
305 'es6': 'es6 modules',
306 'custom-dart': 'a custom format used by dartdevc, similar to AMD'
307 },
308 defaultsTo: 'dart')
295 309
296 // general options 310 // general options
297 ..addFlag('help', abbr: 'h', help: 'Display this message') 311 ..addFlag('help', abbr: 'h', help: 'Display this message')
298 ..addFlag('version', 312 ..addFlag('version',
299 negatable: false, help: 'Display the Dev Compiler verion') 313 negatable: false, help: 'Display the Dev Compiler verion')
300 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false) 314 ..addFlag('server', help: 'Run as a development server.', defaultsTo: false)
301 ..addFlag('hashing', 315 ..addFlag('hashing',
302 help: 'Enable hash-based file caching.', defaultsTo: null) 316 help: 'Enable hash-based file caching.', defaultsTo: null)
303 ..addFlag('widget', 317 ..addFlag('widget',
304 help: 'Serve embedded widget with static errors and warnings.', 318 help: 'Serve embedded widget with static errors and warnings.',
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // The pub-cache directory is two levels up, but we verify that the layout 394 // The pub-cache directory is two levels up, but we verify that the layout
381 // looks correct. 395 // looks correct.
382 if (path.basename(dir) != 'dev_compiler') return null; 396 if (path.basename(dir) != 'dev_compiler') return null;
383 dir = path.dirname(dir); 397 dir = path.dirname(dir);
384 if (path.basename(dir) != 'global_packages') return null; 398 if (path.basename(dir) != 'global_packages') return null;
385 dir = path.dirname(dir); 399 dir = path.dirname(dir);
386 return path.join(dir, cacheDir, 'lib', 'runtime'); 400 return path.join(dir, cacheDir, 'lib', 'runtime');
387 } 401 }
388 return null; 402 return null;
389 } 403 }
OLDNEW
« lib/src/js/nodes.dart ('K') | « lib/src/js/template.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698