Files
ts-node/tests/spy-swc-transpiler.js
Andrew BradleyandGitHub 4788f2d7a5 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
2021-11-03 01:41:33 -04:00

17 lines
542 B
JavaScript

// 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;
};