-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/typescript): Correctly handle ESM context (#9490)
**Related issue:** - nodejs/node#54514
- Loading branch information
1 parent
1e1b165
commit fc0483c
Showing
52 changed files
with
108 additions
and
225 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
swc_ecma_transforms_typescript: patch | ||
swc_core: patch | ||
--- | ||
|
||
fix(es/typescript): Correctly handle ESM context |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,3 @@ | |
//! `---- | ||
//// [/project/index.ts] | ||
function handleError(err) {} | ||
export { }; |
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 |
---|---|---|
|
@@ -8,4 +8,3 @@ | |
//! 3 | | ||
//! `---- | ||
//// [/project/index.ts] | ||
export { }; |
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 |
---|---|---|
|
@@ -11,4 +11,3 @@ var M; | |
})(M || (M = {})); | ||
var myA = M.A; | ||
new myA; | ||
export { }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,3 @@ function fundule() { | |
var p; | ||
var p; | ||
var p; | ||
export { }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,3 @@ var E; | |
E[E["Red"] = 0] = "Red"; | ||
E[E["Blue"] = 1] = "Blue"; | ||
})(E || (E = {})); | ||
export { }; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.1.normal.js
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//// [moduleResolutionWithoutExtension2.ts] | ||
//// [/src/buzz.mts] | ||
// Extensionless relative path cjs import in an ES module | ||
export { }; // should error, should not ask for extension | ||
// should error, should not ask for extension |
1 change: 0 additions & 1 deletion
1
crates/swc/tests/tsc-references/moduleResolutionWithoutExtension2.2.minified.js
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
//// [moduleResolutionWithoutExtension2.ts] | ||
//// [/src/buzz.mts] | ||
export { }; |
2 changes: 1 addition & 1 deletion
2
crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.1.normal.js
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//// [moduleResolutionWithoutExtension7.ts] | ||
//// [/src/bar.cts] | ||
// Extensionless relative path cjs import in a cjs module | ||
export { }; // should error, should not ask for extension | ||
// should error, should not ask for extension |
1 change: 0 additions & 1 deletion
1
crates/swc/tests/tsc-references/moduleResolutionWithoutExtension7.2.minified.js
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
//// [moduleResolutionWithoutExtension7.ts] | ||
//// [/src/bar.cts] | ||
export { }; |
1 change: 0 additions & 1 deletion
1
crates/swc/tests/tsc-references/parserImportDeclaration1.1.normal.js
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
//// [parserImportDeclaration1.ts] | ||
export { }; |
1 change: 0 additions & 1 deletion
1
crates/swc/tests/tsc-references/parserImportDeclaration1.2.minified.js
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
//// [parserImportDeclaration1.ts] | ||
export { }; |
1 change: 0 additions & 1 deletion
1
crates/swc/tests/tsc-references/scannerImportDeclaration1.1.normal.js
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
//// [scannerImportDeclaration1.ts] | ||
export { }; |
1 change: 0 additions & 1 deletion
1
crates/swc/tests/tsc-references/scannerImportDeclaration1.2.minified.js
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
//// [scannerImportDeclaration1.ts] | ||
export { }; |
8 changes: 2 additions & 6 deletions
8
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.amd.ts
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
3 changes: 0 additions & 3 deletions
3
...s/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.cts
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
13 changes: 4 additions & 9 deletions
13
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/1/output.umd.ts
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
8 changes: 2 additions & 6 deletions
8
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.amd.ts
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
3 changes: 0 additions & 3 deletions
3
...s/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.cts
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
13 changes: 4 additions & 9 deletions
13
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/2/output.umd.ts
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
8 changes: 2 additions & 6 deletions
8
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.amd.ts
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
3 changes: 0 additions & 3 deletions
3
...s/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.cts
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
13 changes: 4 additions & 9 deletions
13
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/3/output.umd.ts
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
8 changes: 2 additions & 6 deletions
8
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.amd.ts
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
3 changes: 0 additions & 3 deletions
3
...s/swc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.cts
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
13 changes: 4 additions & 9 deletions
13
...wc_ecma_transforms_module/tests/fixture/common/amd-triple-slash-directive/4/output.umd.ts
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
8 changes: 2 additions & 6 deletions
8
...ecma_transforms_module/tests/fixture/common/cts-import-export/export-assign/output.amd.ts
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 |
---|---|---|
@@ -1,11 +1,7 @@ | ||
define([ | ||
"require", | ||
"exports" | ||
], function(require, exports) { | ||
"require" | ||
], function(require) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const foo = require("foo"); | ||
module.exports = foo; | ||
}); |
3 changes: 0 additions & 3 deletions
3
...wc_ecma_transforms_module/tests/fixture/common/cts-import-export/export-assign/output.cts
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const foo = require("foo"); | ||
module.exports = foo; |
Oops, something went wrong.