Skip to content

Commit

Permalink
Use babel-node instead of ts-node when running benchmark script
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed May 11, 2023
1 parent 82096a1 commit e409bfb
Show file tree
Hide file tree
Showing 3 changed files with 591 additions and 362 deletions.
24 changes: 18 additions & 6 deletions javascript/just.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,25 @@ function babelTransformTask(opts: {dir: string}) {
function runBenchTask() {
return () => {
const files = glob.sync('./tests/Benchmarks/**/*');
const args = ['./tests/bin/run-bench.ts', ...files];
logger.info(args.join(' '));

return spawn(node, args, {
stdio: 'inherit',
env: {NODE_OPTIONS: '-r ts-node/register'},
});
const args = [
'--extensions',
'.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',
},
);
};
}

Expand Down
1 change: 1 addition & 0 deletions javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.7",
"@babel/eslint-parser": "^7.19.1",
"@babel/node": "^7.20.7",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.21.4",
"@types/glob": "^8.1.0",
Expand Down
Loading

0 comments on commit e409bfb

Please sign in to comment.