-
Notifications
You must be signed in to change notification settings - Fork 460
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
[Bug]: Huge performance drop when "allowJs": true is enabled in tsconfig #4294
Comments
Related: #1115 |
Found a workaround, suggested by the warning message when you disable "allowJs" :
'transform': {
'^.+\\.ts$': 'ts-jest', // << selects only ts. It was previously '^.+\\.(j|t)s$'
}, This is still an issue. This needs to be documented, as I had this issue since at least january and I had to investigate since I cleared my jest cache. |
A bit background for this issue: In general, setting Currently there are 2 workarounds:
With the release of typescript 5.5, now we can actually use other transpilers like |
Good to know, thanks for the answer @ahnpnl ! Isolated modules did not solve the issue for me, but removing js files from ts-jest fixed it. I just created another issue here : thisismydesign/nestjs-starter#468 |
What is the issue with |
The reproduction repo has the isolatedModules set to true and my measurements takes account of this. |
But the slowness is only due to js files being included in the transformer regex. isolatedModules does not seems to have any issue. |
I see. Yes in this case Jest will give both js and ts to Theoretically if using fast transpiler like swc, it should be better. However, the recommendation is still only transform what is needed. |
For sure ! In fact, to solve this issue, only a simple warning in the documentation would be required. We cannot do much to solve this, as in order to get this behavior, you need a configuration that is not recommended. |
I agree, I will update documentation to have a note about this. Thanks for the suggestion! |
Created a documentation PR to fix this : #4567 |
Solves #4294 Allowing ts-jest to process javascript files is rarely useful and mau cause extremely long delays when importing modules.
Thank you all for the solutions. Just to give some insights about what it can improve:
@ahnpnl I think the documentation could both mention:
|
Version
at least since 0.3.3, tried in 0.5.3 and looks even worse (no proofs though)
Steps to reproduce
Minimal reproduction repository : https://github.com/LoganTann/tsjest-performance-issue-reproduction
npm i
npm run test
Expected behavior
Actual behavior
Simple test is taking an extremely long time (> 10min) to load the dependency
Disabling the {allowJs} property in the tsconfig file will make the test run under 8 seconds. However, jest will print over 1400 warnings (executed
grep " file to compile while" output_nojs.log | wc -l
).After a successful run, later tests are expected to be much faster thanks to the caching.
Debug log
Interrupted execution, took too much time.
Additional context
Performance measures I did five months ago (under 0.3.3)
Environment
The text was updated successfully, but these errors were encountered: