Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External module bundling #4754

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace ts {

let compilerOptions = host.getCompilerOptions();
let languageVersion = compilerOptions.target || ScriptTarget.ES3;
let modulekind = compilerOptions.module ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;
let modulekind = (compilerOptions.module !== undefined && compilerOptions.module !== null) ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.None;

let emitResolver = createResolver();

Expand Down
9 changes: 8 additions & 1 deletion src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ namespace ts {
name: "module",
shortName: "m",
type: {
"none": ModuleKind.None,
"commonjs": ModuleKind.CommonJS,
"amd": ModuleKind.AMD,
"system": ModuleKind.System,
"umd": ModuleKind.UMD,
"es6": ModuleKind.ES6,
},
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es6,
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_es6_or_none_only_valid_with_bundle,
paramType: Diagnostics.KIND,
error: Diagnostics.Argument_for_module_option_must_be_commonjs_amd_system_umd_or_es6
},
Expand Down Expand Up @@ -246,6 +247,12 @@ namespace ts {
},
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic,
},
{
name: "bundle",
type: "string",
isFilePath: true,
description: Diagnostics.Specifies_entrypoint_file_for_bundling
}
];

Expand Down
28 changes: 28 additions & 0 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ namespace ts {
}
return result;
}

export function pairwiseMap<T, U>(map: Map<T>, f: (key: string, value: T) => U): U[] {
let result: U[];
if (map) {
result = [];
for (let k in map) {
result.push(f(k, map[k]));
}
}
return result;
}

export function flatten<T>(array: T[][]): T[] {
if (array) {
return [].concat(...array);
}
return;
}

export function keys(map: Map<any>): string[] {
let result: string[] = [];
if (map) {
for (let k in map) {
result.push(k);
}
}
return result;
}

export function concatenate<T>(array1: T[], array2: T[]): T[] {
if (!array2 || !array2.length) return array1;
Expand Down
14 changes: 13 additions & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,10 @@
"category": "Error",
"code": 1215
},
"Cannot use option '--module none' without using '--bundle'.": {
"category": "Error",
"code": 1216
},
"Export assignment is not supported when '--module' flag is 'system'.": {
"category": "Error",
"code": 1218
Expand Down Expand Up @@ -2056,6 +2060,10 @@
"category": "Error",
"code": 5054
},
"Option '{0}' requires both '{1}' and '{2}'.": {
"category": "Error",
"code": 5055
},

"Concatenate and emit output to single file.": {
"category": "Message",
Expand Down Expand Up @@ -2101,7 +2109,7 @@
"category": "Message",
"code": 6015
},
"Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es6'": {
"Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es6', or 'none' (only valid with --bundle)": {
"category": "Message",
"code": 6016
},
Expand Down Expand Up @@ -2294,6 +2302,10 @@
"category": "Message",
"code": 6072
},
"Specifies entrypoint file for bundling.": {
"category": "Message",
"code": 6073
},

"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
Expand Down
Loading