-
Notifications
You must be signed in to change notification settings - Fork 12.8k
fixes #1908 enhancement request #1909
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9974526
updated code style, added tests, fixed regex bug, merged to latest br…
v3nom 3699057
Added AMD dependency reordering, so import order matches with provide…
v3nom a27a893
previous AMD ordering was not correct
v3nom 8492dfd
moved AMD module sorting to emitter, updated test case
v3nom 091f38b
improved equality checks in AMD module sorting function
v3nom d94cbed
Merge remote-tracking branch 'upstream/master'
v3nom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ scripts/ior.js | |
scripts/*.js.map | ||
coverage/ | ||
internal/ | ||
**/.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/amdDependencyCommentName1.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests/cases/compiler/amdDependencyCommentName1.ts(3,21): error TS2307: Cannot find external module 'm2'. | ||
|
||
|
||
==== tests/cases/compiler/amdDependencyCommentName1.ts (1 errors) ==== | ||
///<amd-dependency path='bar' name='b'/> | ||
|
||
import m1 = require("m2") | ||
~~~~ | ||
!!! error TS2307: Cannot find external module 'm2'. | ||
m1.f(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//// [amdDependencyCommentName1.ts] | ||
///<amd-dependency path='bar' name='b'/> | ||
|
||
import m1 = require("m2") | ||
m1.f(); | ||
|
||
//// [amdDependencyCommentName1.js] | ||
///<amd-dependency path='bar' name='b'/> | ||
var m1 = require("m2"); | ||
m1.f(); |
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/amdDependencyCommentName2.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tests/cases/compiler/amdDependencyCommentName2.ts(3,21): error TS2307: Cannot find external module 'm2'. | ||
|
||
|
||
==== tests/cases/compiler/amdDependencyCommentName2.ts (1 errors) ==== | ||
///<amd-dependency path='bar' name='b'/> | ||
|
||
import m1 = require("m2") | ||
~~~~ | ||
!!! error TS2307: Cannot find external module 'm2'. | ||
m1.f(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//// [amdDependencyCommentName2.ts] | ||
///<amd-dependency path='bar' name='b'/> | ||
|
||
import m1 = require("m2") | ||
m1.f(); | ||
|
||
//// [amdDependencyCommentName2.js] | ||
///<amd-dependency path='bar' name='b'/> | ||
define(["require", "exports", "m2", "bar"], function (require, exports, m1, b) { | ||
m1.f(); | ||
}); |
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/amdDependencyCommentName3.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", "bar", "goo", "foo"], function (require, exports, m1, b, c) { | ||
m1.f(); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//@module: commonjs | ||
///<amd-dependency path='bar' name='b'/> | ||
|
||
import m1 = require("m2") | ||
m1.f(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//@module: amd | ||
///<amd-dependency path='bar' name='b'/> | ||
|
||
import m1 = require("m2") | ||
m1.f(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if you have multiple dependencies, ones with names and ones without. this will get the order our of sync, since name is optional and path is not. e.g.:
will emit:
which is not what you want. so either you reorder them, so that ones with names come first, which we do not do usually as we like to keep emitted code as close as possible to generated code. or you give the other ones unused random names consider using createTempVariable utility in the emitter.
Also worth adding a new test for this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving random names would add unnecessary garbage to emitted code. Since import order does not matter for AMD modules, reordering would make most sense.
Changing order is a bit intrusive to original code, but amd-dependency comment is not a language feature, just a utility. Its also not documented in official materials, so I think violating some project principles is justifiable.