-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --swc shorthand for the built-in swc transpiler; graduate the swc…
… transpiler out of experimental status (#1536) * Add --swc shorthand for the built-in swc transpiler; graduate the swc transpiler out of experimental status * lint-fix * fix * fix tests * Improve swc / transpiler tests to prove that third-party transpiler was invoked * lintfix
- Loading branch information
Showing
15 changed files
with
138 additions
and
34 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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Spy on the swc transpiler so that tests can prove it was used rather than | ||
// TypeScript's `transpileModule`. | ||
const swcTranspiler = require('ts-node/transpilers/swc'); | ||
|
||
global.swcTranspilerCalls = 0; | ||
|
||
const wrappedCreate = swcTranspiler.create; | ||
swcTranspiler.create = function (...args) { | ||
const transpiler = wrappedCreate(...args); | ||
const wrappedTranspile = transpiler.transpile; | ||
transpiler.transpile = function (...args) { | ||
global.swcTranspilerCalls++; | ||
return wrappedTranspile.call(this, ...args); | ||
}; | ||
return transpiler; | ||
}; |
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 @@ | ||
// Test for #1343 | ||
const Decorator = function () {}; | ||
@Decorator | ||
class World {} | ||
|
||
// intentional type errors to check transpile-only ESM loader skips type checking | ||
parseInt(1101, 2); | ||
const x: number = `Hello ${World.name}! swc transpiler invocation count: ${global.swcTranspilerCalls}`; | ||
console.log(x); | ||
|
||
// test module type emit | ||
import { readFileSync } from 'fs'; | ||
readFileSync; |
12 changes: 12 additions & 0 deletions
12
tests/transpile-only-swc-shorthand-via-tsconfig/tsconfig.json
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,12 @@ | ||
{ | ||
"ts-node": { | ||
"swc": true | ||
}, | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "CommonJS", | ||
"allowJs": true, | ||
"jsx": "react", | ||
"experimentalDecorators": true | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../dist/transpilers/swc') |
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