Use babel-node instead of ts-node when running benchmark script

Summary:
`ts-node` does transformation using tsc. Do transformation with Babel instead so that the generation is consistent with Jest and the packed output.

We still need `ts-node` around since various systems rely on it being present to enable `.ts` config files.

This also enables transformation of any JS files.

Reviewed By: yungsters

Differential Revision: D45722106

fbshipit-source-id: 51b7a4f6a1532bea1133d59e626297d3b40f1762
This commit is contained in:
Nick Gerleman
2023-05-10 17:12:10 -07:00
committed by Facebook GitHub Bot
parent 82096a1465
commit e409bfb43a
3 changed files with 591 additions and 362 deletions

View File

@@ -139,13 +139,25 @@ function babelTransformTask(opts: {dir: string}) {
function runBenchTask() { function runBenchTask() {
return () => { return () => {
const files = glob.sync('./tests/Benchmarks/**/*'); const files = glob.sync('./tests/Benchmarks/**/*');
const args = ['./tests/bin/run-bench.ts', ...files];
logger.info(args.join(' '));
return spawn(node, args, { const args = [
stdio: 'inherit', '--extensions',
env: {NODE_OPTIONS: '-r ts-node/register'}, '.js,.ts',
}); '--config-file',
path.join(__dirname, '.babelrc.js'),
'--',
'./tests/bin/run-bench.ts',
...files,
];
logger.info(['babel-node', ...args].join(' '));
return spawn(
node,
[require.resolve('@babel/node/bin/babel-node'), ...args],
{
stdio: 'inherit',
},
);
}; };
} }

View File

@@ -44,6 +44,7 @@
"@babel/cli": "^7.20.7", "@babel/cli": "^7.20.7",
"@babel/core": "^7.20.7", "@babel/core": "^7.20.7",
"@babel/eslint-parser": "^7.19.1", "@babel/eslint-parser": "^7.19.1",
"@babel/node": "^7.20.7",
"@babel/preset-env": "^7.20.2", "@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.21.4", "@babel/preset-typescript": "^7.21.4",
"@types/glob": "^8.1.0", "@types/glob": "^8.1.0",

File diff suppressed because it is too large Load Diff