mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
moved AMD module sorting to emitter, updated test case
This commit is contained in:
parent
a27a893eeb
commit
8492dfdffd
@ -3902,11 +3902,25 @@ module ts {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sortAMDModules(amdModules: {name: string; path: string}[]) {
|
||||
// AMD modules with declared variable names goes first
|
||||
return amdModules.sort((moduleA, moduleB) => {
|
||||
if (moduleA.name == moduleB.name) {
|
||||
return 0;
|
||||
} else if (moduleA.name == undefined) {
|
||||
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 + "\", ");
|
||||
}
|
||||
|
||||
@ -4719,12 +4719,7 @@ module ts {
|
||||
var nameMatchResult = nameRegex.exec(comment);
|
||||
if (pathMatchResult) {
|
||||
var amdDependency = {path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined };
|
||||
// AMD dependencies with names have to go first in define header
|
||||
if (nameMatchResult) {
|
||||
amdDependencies.unshift(amdDependency);
|
||||
} else {
|
||||
amdDependencies.push(amdDependency);
|
||||
}
|
||||
amdDependencies.push(amdDependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,6 @@ m1.f();
|
||||
///<amd-dependency path='bar' name='b'/>
|
||||
///<amd-dependency path='foo'/>
|
||||
///<amd-dependency path='goo' name='c'/>
|
||||
define(["require", "exports", "m2", "goo", "bar", "foo"], function (require, exports, m1, c, b) {
|
||||
define(["require", "exports", "m2", "bar", "goo", "foo"], function (require, exports, m1, b, c) {
|
||||
m1.f();
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user