TypeStrong / ts-node

TypeScript execution and REPL for node.js
https://typestrong.org/ts-node
MIT License
12.92k stars 532 forks source link

Slow import using allowJs option #2137

Open Pavel-Boyazov opened 1 month ago

Pavel-Boyazov commented 1 month ago

Search Terms

Slow import Long time import

Expected Behavior

Speed regardless of the indication of allowJs

Actual Behavior

Import without allowJs option takes about 0.5 ms Import with allowJs option is true takes about 43 ms

Steps to reproduce the problem

  1. Create commonJS file with other files imports
  2. Compare speed with allowJs using and without

Minimal reproduction

const fs = require("fs");

fs.writeFileSync(`${__dirname}/t1.cjs`, "module.exports = 1");

console.time(-1);

const t = require("./t1.cjs");

console.timeEnd(-1);

fs.unlinkSync(`${__dirname}/t1.cjs`);

Specifications