Added AMD dependency reordering, so import order matches with provided names

This commit is contained in:
togru
2015-02-09 08:44:34 +01:00
parent 9974526101
commit 36990570c4
4 changed files with 41 additions and 1 deletions
+7 -1
View File
@@ -4718,7 +4718,13 @@ module ts {
var pathMatchResult = pathRegex.exec(comment);
var nameMatchResult = nameRegex.exec(comment);
if (pathMatchResult) {
amdDependencies.push({path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined });
var amdDependency = {path: pathMatchResult[2], name: nameMatchResult ? nameMatchResult[2] : undefined };
// AMD dependencies with names have to go first in define header
if (nameMatchResult) {
amdDependencies.push(amdDependency);
} else {
amdDependencies.unshift(amdDependency);
}
}
}
}
@@ -0,0 +1,12 @@
tests/cases/compiler/amdDependencyCommentName3.ts(5,21): error TS2307: Cannot find external module 'm2'.
==== tests/cases/compiler/amdDependencyCommentName3.ts (1 errors) ====
///<amd-dependency path='bar' name='b'/>
///<amd-dependency path='foo'/>
///<amd-dependency path='goo' name='c'/>
import m1 = require("m2")
~~~~
!!! error TS2307: Cannot find external module 'm2'.
m1.f();
@@ -0,0 +1,15 @@
//// [amdDependencyCommentName3.ts]
///<amd-dependency path='bar' name='b'/>
///<amd-dependency path='foo'/>
///<amd-dependency path='goo' name='c'/>
import m1 = require("m2")
m1.f();
//// [amdDependencyCommentName3.js]
///<amd-dependency path='bar' name='b'/>
///<amd-dependency path='foo'/>
///<amd-dependency path='goo' name='c'/>
define(["require", "exports", "m2", "foo", "bar", "goo"], function (require, exports, m1, b, c) {
m1.f();
});
@@ -0,0 +1,7 @@
//@module: amd
///<amd-dependency path='bar' name='b'/>
///<amd-dependency path='foo'/>
///<amd-dependency path='goo' name='c'/>
import m1 = require("m2")
m1.f();