mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript into esSymbols
This commit is contained in:
@@ -4061,11 +4061,25 @@ module ts {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sortAMDModules(amdModules: {name: string; path: string}[]) {
|
||||
// AMD modules with declared variable names go first
|
||||
return amdModules.sort((moduleA, moduleB) => {
|
||||
if (moduleA.name === moduleB.name) {
|
||||
return 0;
|
||||
} else if (!moduleA.name) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function emitAMDModule(node: SourceFile, startIndex: number) {
|
||||
var imports = getExternalImportDeclarations(node);
|
||||
writeLine();
|
||||
write("define(");
|
||||
sortAMDModules(node.amdDependencies);
|
||||
if (node.amdModuleName) {
|
||||
write("\"" + node.amdModuleName + "\", ");
|
||||
}
|
||||
@@ -4075,7 +4089,7 @@ module ts {
|
||||
emitLiteral(<LiteralExpression>getExternalModuleImportDeclarationExpression(imp));
|
||||
});
|
||||
forEach(node.amdDependencies, amdDependency => {
|
||||
var text = "\"" + amdDependency + "\"";
|
||||
var text = "\"" + amdDependency.path + "\"";
|
||||
write(", ");
|
||||
write(text);
|
||||
});
|
||||
@@ -4084,6 +4098,12 @@ module ts {
|
||||
write(", ");
|
||||
emit(imp.name);
|
||||
});
|
||||
forEach(node.amdDependencies, amdDependency => {
|
||||
if (amdDependency.name) {
|
||||
write(", ");
|
||||
write(amdDependency.name);
|
||||
}
|
||||
});
|
||||
write(") {");
|
||||
increaseIndent();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
|
||||
@@ -4751,7 +4751,7 @@ module ts {
|
||||
function processReferenceComments(sourceFile: SourceFile): void {
|
||||
var triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, sourceText);
|
||||
var referencedFiles: FileReference[] = [];
|
||||
var amdDependencies: string[] = [];
|
||||
var amdDependencies: {path: string; name: string}[] = [];
|
||||
var amdModuleName: string;
|
||||
|
||||
// Keep scanning all the leading trivia in the file until we get to something that
|
||||
@@ -4791,10 +4791,17 @@ module ts {
|
||||
amdModuleName = amdModuleNameMatchResult[2];
|
||||
}
|
||||
|
||||
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s+path\s*=\s*('|")(.+?)\1/gim;
|
||||
var amdDependencyRegEx = /^\/\/\/\s*<amd-dependency\s/gim;
|
||||
var pathRegex = /\spath\s*=\s*('|")(.+?)\1/gim;
|
||||
var nameRegex = /\sname\s*=\s*('|")(.+?)\1/gim;
|
||||
var amdDependencyMatchResult = amdDependencyRegEx.exec(comment);
|
||||
if (amdDependencyMatchResult) {
|
||||
amdDependencies.push(amdDependencyMatchResult[2]);
|
||||
var pathMatchResult = pathRegex.exec(comment);
|
||||
var nameMatchResult = nameRegex.exec(comment);
|
||||
if (pathMatchResult) {
|
||||
var amdDependency = {path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined };
|
||||
amdDependencies.push(amdDependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,7 +888,7 @@ module ts {
|
||||
fileName: string;
|
||||
text: string;
|
||||
|
||||
amdDependencies: string[];
|
||||
amdDependencies: {path: string; name: string}[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
|
||||
|
||||
@@ -725,7 +725,7 @@ module ts {
|
||||
public statements: NodeArray<Statement>;
|
||||
public endOfFileToken: Node;
|
||||
|
||||
public amdDependencies: string[];
|
||||
public amdDependencies: {name: string; path: string}[];
|
||||
public amdModuleName: string;
|
||||
public referencedFiles: FileReference[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user