Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow import using allowJs option #2137

Open
Pavel-Boyazov opened this issue Oct 6, 2024 · 0 comments
Open

Slow import using allowJs option #2137

Pavel-Boyazov opened this issue Oct 6, 2024 · 0 comments

Comments

@Pavel-Boyazov
Copy link

Pavel-Boyazov commented Oct 6, 2024

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

  • ts-node version: v10.9.2
  • node version: v20.16.0
  • TypeScript version: v5.6.2
  • tsconfig.json, if you're using one:
{
  "compilerOptions": { 
    "allowJs": true,
  },
}

OR

{}
  • package.json:
{
	"devDependencies": {
		"ts-node": "^10.9.2",
		"typescript": "^5.6.2"
	},
}
  • Operating system and version: MacOS 14.1.2
  • If Windows, are you using WSL or WSL2?:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant