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

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: 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') | test/codegen/es6_modules.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..d9980e83de83b83d56fc6e2b96b67983e4fd2385 100644
--- a/lib/src/options.dart
+++ b/lib/src/options.dart
@@ -56,6 +56,13 @@ class SourceResolverOptions {
this.useImplicitHtml: false});
}
+enum ModuleFormat {
+ es6, dart
+}
+
+ModuleFormat parseModuleFormat(String s) =>
+ ModuleFormat.values.firstWhere((v) => s == '$v'.split('.')[1]);
+
// TODO(jmesserly): refactor all codegen options here.
class CodegenOptions {
/// Whether to emit the source map files.
@@ -79,7 +86,7 @@ class CodegenOptions {
/// Which module format to support.
/// Currently 'es6' and 'dart' are supported.
- final String moduleFormat;
+ final ModuleFormat moduleFormat;
const CodegenOptions(
{this.emitSourceMaps: true,
@@ -88,7 +95,7 @@ class CodegenOptions {
this.destructureNamedParams: _DESTRUCTURE_NAMED_PARAMS_DEFAULT,
this.outputDir,
this.arrowFnBindThisWorkaround: false,
- this.moduleFormat: 'dart'});
+ this.moduleFormat: ModuleFormat.dart});
}
/// Options for devrun.
@@ -158,7 +165,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 +246,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,
@@ -309,7 +316,7 @@ final ArgParser argParser = new ArgParser()
allowed: ['es6', 'dart'],
allowedHelp: {
'es6': 'es6 modules',
- 'custom-dart': 'a custom format used by dartdevc, similar to AMD'
+ 'dart': 'a custom format used by dartdevc, similar to AMD'
},
defaultsTo: 'dart')
« no previous file with comments | « lib/src/js/nodes.dart ('k') | test/codegen/es6_modules.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698