Skip to content

Commit e8fcf8f

Browse files
committed
initial support for system module
1 parent ad477c7 commit e8fcf8f

8 files changed

+366
-57
lines changed

Diff for: src/compiler/checker.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -10616,9 +10616,15 @@ module ts {
1061610616

1061710617
checkExternalModuleExports(container);
1061810618

10619-
if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) {
10620-
// export assignment is deprecated in es6 or above
10621-
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
10619+
if (node.isExportEquals) {
10620+
if (languageVersion >= ScriptTarget.ES6) {
10621+
// export assignment is deprecated in es6 or above
10622+
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
10623+
}
10624+
else if (compilerOptions.module === ModuleKind.System) {
10625+
// system modules does not support export assignment
10626+
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_with_module_flag_is_system);
10627+
}
1062210628
}
1062310629
}
1062410630

@@ -11432,9 +11438,11 @@ module ts {
1143211438

1143311439
function getExportNameSubstitution(symbol: Symbol, location: Node, getGeneratedNameForNode: (Node: Node) => string): string {
1143411440
if (isExternalModuleSymbol(symbol.parent)) {
11435-
// If this is es6 or higher, just use the name of the export
11441+
// 1. If this is es6 or higher, just use the name of the export
1143611442
// no need to qualify it.
11437-
if (languageVersion >= ScriptTarget.ES6) {
11443+
// 2. export mechanism for System modules is different from CJS\AMD
11444+
// and it does not need qualifications for exports
11445+
if (languageVersion >= ScriptTarget.ES6 || compilerOptions.module === ModuleKind.System) {
1143811446
return undefined;
1143911447
}
1144011448
return "exports." + unescapeIdentifier(symbol.name);

Diff for: src/compiler/commandLineParser.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ module ts {
5050
shortName: "m",
5151
type: {
5252
"commonjs": ModuleKind.CommonJS,
53-
"amd": ModuleKind.AMD
53+
"amd": ModuleKind.AMD,
54+
"system": ModuleKind.System,
5455
},
55-
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd,
56+
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_system_or_amd,
5657
paramType: Diagnostics.KIND,
57-
error: Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd
58+
error: Diagnostics.Argument_for_module_option_must_be_commonjs_system_or_amd
5859
},
5960
{
6061
name: "noEmit",

Diff for: src/compiler/diagnosticInformationMap.generated.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,15 @@ module ts {
161161
A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." },
162162
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
163163
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
164-
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
164+
Cannot_compile_external_modules_into_amd_system_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd, system or commonjs when targeting es6 or higher." },
165165
Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
166166
Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." },
167167
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
168168
Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." },
169169
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
170170
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
171171
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
172+
Export_assignment_is_not_supported_with_module_flag_is_system: { code: 1212, category: DiagnosticCategory.Error, key: "Export assignment is not supported with '--module' flag is 'system'." },
172173
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
173174
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
174175
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -456,7 +457,7 @@ module ts {
456457
Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." },
457458
Do_not_emit_outputs: { code: 6010, category: DiagnosticCategory.Message, key: "Do not emit outputs." },
458459
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
459-
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },
460+
Specify_module_code_generation_Colon_commonjs_system_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs', 'system' or 'amd'" },
460461
Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." },
461462
Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." },
462463
Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." },
@@ -477,7 +478,7 @@ module ts {
477478
Generates_corresponding_map_file: { code: 6043, category: DiagnosticCategory.Message, key: "Generates corresponding '.map' file." },
478479
Compiler_option_0_expects_an_argument: { code: 6044, category: DiagnosticCategory.Error, key: "Compiler option '{0}' expects an argument." },
479480
Unterminated_quoted_string_in_response_file_0: { code: 6045, category: DiagnosticCategory.Error, key: "Unterminated quoted string in response file '{0}'." },
480-
Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." },
481+
Argument_for_module_option_must_be_commonjs_system_or_amd: { code: 6046, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs', 'system' or 'amd'." },
481482
Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." },
482483
Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: DiagnosticCategory.Error, key: "Locale must be of the form <language> or <language>-<territory>. For example '{0}' or '{1}'." },
483484
Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },

Diff for: src/compiler/diagnosticMessages.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@
635635
"category": "Error",
636636
"code": 1203
637637
},
638-
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
638+
"Cannot compile external modules into amd, system or commonjs when targeting es6 or higher.": {
639639
"category": "Error",
640640
"code": 1204
641641
},
@@ -667,6 +667,10 @@
667667
"category": "Error",
668668
"code": 1211
669669
},
670+
"Export assignment is not supported with '--module' flag is 'system'.": {
671+
"category": "Error",
672+
"code": 1212
673+
},
670674
"Duplicate identifier '{0}'.": {
671675
"category": "Error",
672676
"code": 2300
@@ -1816,7 +1820,7 @@
18161820
"category": "Message",
18171821
"code": 6015
18181822
},
1819-
"Specify module code generation: 'commonjs' or 'amd'": {
1823+
"Specify module code generation: 'commonjs', 'system' or 'amd'": {
18201824
"category": "Message",
18211825
"code": 6016
18221826
},
@@ -1900,7 +1904,7 @@
19001904
"category": "Error",
19011905
"code": 6045
19021906
},
1903-
"Argument for '--module' option must be 'commonjs' or 'amd'.": {
1907+
"Argument for '--module' option must be 'commonjs', 'system' or 'amd'.": {
19041908
"category": "Error",
19051909
"code": 6046
19061910
},

0 commit comments

Comments
 (0)