-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
improve module loading interoperability for babel #3586
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
54a4e9e
improve module loading interoperability for babel
vvakame 3aba5aa
do not use `Object.defineProperty` in es3 target
vvakame e9d590f
PR feedback
vvakame 75466e6
Merge branch 'master' into addEsModule
vvakame 86d106a
PR feedback
vvakame a512e9e
PR feedback
vvakame 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 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 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,27 @@ | ||
//// [es5-commonjs.ts] | ||
|
||
export default class A | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
{ | ||
return 42; | ||
} | ||
} | ||
|
||
|
||
//// [es5-commonjs.js] | ||
var A = (function () { | ||
function A() { | ||
} | ||
A.prototype.B = function () { | ||
return 42; | ||
}; | ||
return A; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = A; |
This file contains 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,17 @@ | ||
=== tests/cases/compiler/es5-commonjs.ts === | ||
|
||
export default class A | ||
>A : Symbol(A, Decl(es5-commonjs.ts, 0, 0)) | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
>B : Symbol(B, Decl(es5-commonjs.ts, 6, 5)) | ||
{ | ||
return 42; | ||
} | ||
} | ||
|
This file contains 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,18 @@ | ||
=== tests/cases/compiler/es5-commonjs.ts === | ||
|
||
export default class A | ||
>A : A | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
>B : () => number | ||
{ | ||
return 42; | ||
>42 : number | ||
} | ||
} | ||
|
This file contains 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,8 @@ | ||
//// [es5-commonjs2.ts] | ||
|
||
export default 1; | ||
|
||
|
||
//// [es5-commonjs2.js] | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = 1; |
This file contains 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 @@ | ||
=== tests/cases/compiler/es5-commonjs2.ts === | ||
|
||
No type information for this code.export default 1; | ||
No type information for this code. | ||
No type information for this code. |
This file contains 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 @@ | ||
=== tests/cases/compiler/es5-commonjs2.ts === | ||
|
||
No type information for this code.export default 1; | ||
No type information for this code. | ||
No type information for this code. |
This file contains 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,9 @@ | ||
//// [es5-commonjs3.ts] | ||
|
||
export default "test"; | ||
export var __esModule = 1; | ||
|
||
|
||
//// [es5-commonjs3.js] | ||
exports.default = "test"; | ||
exports.__esModule = 1; |
This file contains 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,6 @@ | ||
=== tests/cases/compiler/es5-commonjs3.ts === | ||
|
||
export default "test"; | ||
export var __esModule = 1; | ||
>__esModule : Symbol(__esModule, Decl(es5-commonjs3.ts, 2, 10)) | ||
|
This file contains 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 @@ | ||
=== tests/cases/compiler/es5-commonjs3.ts === | ||
|
||
export default "test"; | ||
export var __esModule = 1; | ||
>__esModule : number | ||
>1 : number | ||
|
This file contains 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,28 @@ | ||
//// [es5-commonjs4.ts] | ||
|
||
export default class A | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
{ | ||
return 42; | ||
} | ||
} | ||
export var __esModule = 1; | ||
|
||
|
||
//// [es5-commonjs4.js] | ||
var A = (function () { | ||
function A() { | ||
} | ||
A.prototype.B = function () { | ||
return 42; | ||
}; | ||
return A; | ||
})(); | ||
exports.default = A; | ||
exports.__esModule = 1; |
This file contains 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,19 @@ | ||
=== tests/cases/compiler/es5-commonjs4.ts === | ||
|
||
export default class A | ||
>A : Symbol(A, Decl(es5-commonjs4.ts, 0, 0)) | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
>B : Symbol(B, Decl(es5-commonjs4.ts, 6, 5)) | ||
{ | ||
return 42; | ||
} | ||
} | ||
export var __esModule = 1; | ||
>__esModule : Symbol(__esModule, Decl(es5-commonjs4.ts, 13, 10)) | ||
|
This file contains 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,21 @@ | ||
=== tests/cases/compiler/es5-commonjs4.ts === | ||
|
||
export default class A | ||
>A : A | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
>B : () => number | ||
{ | ||
return 42; | ||
>42 : number | ||
} | ||
} | ||
export var __esModule = 1; | ||
>__esModule : number | ||
>1 : number | ||
|
This file contains 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,13 @@ | ||
//// [es5-commonjs5.ts] | ||
|
||
export default function () { | ||
return "test"; | ||
} | ||
|
||
|
||
//// [es5-commonjs5.js] | ||
function default_1() { | ||
return "test"; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = default_1; |
This file contains 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 @@ | ||
=== tests/cases/compiler/es5-commonjs5.ts === | ||
|
||
No type information for this code.export default function () { | ||
No type information for this code. return "test"; | ||
No type information for this code.} | ||
No type information for this code. | ||
No type information for this code. |
This file contains 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 @@ | ||
=== tests/cases/compiler/es5-commonjs5.ts === | ||
|
||
export default function () { | ||
return "test"; | ||
>"test" : string | ||
} | ||
|
This file contains 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 @@ | ||
//// [es5-commonjs6.ts] | ||
|
||
export default "test"; | ||
var __esModule = 1; | ||
|
||
|
||
//// [es5-commonjs6.js] | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = "test"; | ||
var __esModule = 1; |
This file contains 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,6 @@ | ||
=== tests/cases/compiler/es5-commonjs6.ts === | ||
|
||
export default "test"; | ||
var __esModule = 1; | ||
>__esModule : Symbol(__esModule, Decl(es5-commonjs6.ts, 2, 3)) | ||
|
This file contains 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 @@ | ||
=== tests/cases/compiler/es5-commonjs6.ts === | ||
|
||
export default "test"; | ||
var __esModule = 1; | ||
>__esModule : number | ||
>1 : number | ||
|
This file contains 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,34 @@ | ||
//// [es5-system.ts] | ||
|
||
export default class A | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
{ | ||
return 42; | ||
} | ||
} | ||
|
||
|
||
//// [es5-system.js] | ||
System.register([], function(exports_1) { | ||
var A; | ||
return { | ||
setters:[], | ||
execute: function() { | ||
A = (function () { | ||
function A() { | ||
} | ||
A.prototype.B = function () { | ||
return 42; | ||
}; | ||
return A; | ||
})(); | ||
exports_1("default", A); | ||
} | ||
} | ||
}); |
This file contains 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,17 @@ | ||
=== tests/cases/compiler/es5-system.ts === | ||
|
||
export default class A | ||
>A : Symbol(A, Decl(es5-system.ts, 0, 0)) | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
>B : Symbol(B, Decl(es5-system.ts, 6, 5)) | ||
{ | ||
return 42; | ||
} | ||
} | ||
|
This file contains 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,18 @@ | ||
=== tests/cases/compiler/es5-system.ts === | ||
|
||
export default class A | ||
>A : A | ||
{ | ||
constructor () | ||
{ | ||
|
||
} | ||
|
||
public B() | ||
>B : () => number | ||
{ | ||
return 42; | ||
>42 : number | ||
} | ||
} | ||
|
This file contains 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 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 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 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 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
Oops, something went wrong.
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.
Should this be an assert too?
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.
@JsonFreeman I think this line is required. if this line changes into
Debug.assert
, we got a assertion error in wrong context.