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

Unified Diff: lib/src/options.dart

Issue 1612083002: Initial --modules=es6 support (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: addressed comments (legacy, doc) + test enum utils Created 4 years, 11 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 | « lib/src/js/nodes.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/options.dart
diff --git a/lib/src/options.dart b/lib/src/options.dart
index cf6aaa6300b91ade67cf0ac39fb50c3b3b99c870..d5abf8d2023e6db63fc36eec8164900eeaeef781 100644
--- a/lib/src/options.dart
+++ b/lib/src/options.dart
@@ -13,6 +13,8 @@ import 'package:logging/logging.dart' show Level;
import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';
+import 'utils.dart' show parseEnum, getEnumName;
+
const String _V8_BINARY_DEFAULT = 'node';
const bool _CLOSURE_DEFAULT = false;
const bool _DESTRUCTURE_NAMED_PARAMS_DEFAULT = false;
@@ -56,6 +58,9 @@ class SourceResolverOptions {
this.useImplicitHtml: false});
}
+enum ModuleFormat { es6, legacy }
+ModuleFormat parseModuleFormat(String s) => parseEnum(s, ModuleFormat.values);
+
// TODO(jmesserly): refactor all codegen options here.
class CodegenOptions {
/// Whether to emit the source map files.
@@ -78,8 +83,8 @@ class CodegenOptions {
final bool arrowFnBindThisWorkaround;
/// Which module format to support.
- /// Currently 'es6' and 'dart' are supported.
- final String moduleFormat;
+ /// Currently 'es6' and 'legacy' are supported.
+ final ModuleFormat moduleFormat;
const CodegenOptions(
{this.emitSourceMaps: true,
@@ -88,7 +93,7 @@ class CodegenOptions {
this.destructureNamedParams: _DESTRUCTURE_NAMED_PARAMS_DEFAULT,
this.outputDir,
this.arrowFnBindThisWorkaround: false,
- this.moduleFormat: 'dart'});
+ this.moduleFormat: ModuleFormat.legacy});
}
/// Options for devrun.
@@ -158,7 +163,7 @@ class CompilerOptions {
/// to this directory.
final String inputBaseDir;
- CompilerOptions(
+ const CompilerOptions(
{this.sourceOptions: const SourceResolverOptions(),
this.codegenOptions: const CodegenOptions(),
this.runnerOptions: const RunnerOptions(),
@@ -239,7 +244,7 @@ CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) {
destructureNamedParams: args['destructure-named-params'],
outputDir: outputDir,
arrowFnBindThisWorkaround: args['arrow-fn-bind-this'],
- moduleFormat: args['modules']),
+ moduleFormat: parseModuleFormat(args['modules'])),
sourceOptions: new SourceResolverOptions(
useMockSdk: args['mock-sdk'],
dartSdkPath: sdkPath,
@@ -306,12 +311,13 @@ final ArgParser argParser = new ArgParser()
help: 'Work around `this` binding in => functions')
..addOption('modules',
help: 'Which module pattern to emit',
- allowed: ['es6', 'dart'],
+ allowed: ModuleFormat.values.map(getEnumName).toList(),
allowedHelp: {
- 'es6': 'es6 modules',
- 'custom-dart': 'a custom format used by dartdevc, similar to AMD'
+ getEnumName(ModuleFormat.es6): 'es6 modules',
+ getEnumName(ModuleFormat.legacy):
+ 'a custom format used by dartdevc, similar to AMD'
},
- defaultsTo: 'dart')
+ defaultsTo: getEnumName(ModuleFormat.legacy))
// general options
..addFlag('help', abbr: 'h', help: 'Display this message')
« no previous file with comments | « lib/src/js/nodes.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698