Comments (10)
Related: #1115
from ts-jest.
Found a workaround, suggested by the warning message when you disable "allowJs" :
- Remove "compilerOptions.allowJs": true in your tsconfig file
- Edit the transform regex to select only typescript files with ts-jest :
'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.
from ts-jest.
A bit background for this issue: ts-jest
internally uses TypeScript compiler API to transform ts/js
file into js
file.
In general, setting allowJs
to true
is necessary if one wants the TypeScript compiler API to load and process JavaScript files in addition to TypeScript files when transforming files. This leads to the result that more files are loaded into memory which can blow up the machine.
Currently there are 2 workarounds:
- Use https://kulshekhar.github.io/ts-jest/docs/getting-started/options/isolatedModules
- Or your solution which tells
ts-jest
not to processjs
file
With the release of typescript 5.5, now we can actually use other transpilers like esbuild
or swc
to process js
files + opt in type checking from new v5.5 API
from ts-jest.
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
It is very likely the previous developer in my project took the ts-config file in this template repo.
from ts-jest.
What is the issue with isolatedModules
that you had? It supposed to be faster with true
value (this is not tsconfig option btw, the name is confusing and we will rename it)
from ts-jest.
The reproduction repo has the isolatedModules set to true and my measurements takes account of this.
https://github.com/LoganTann/tsjest-performance-issue-reproduction/blob/main/jest.config.js
from ts-jest.
But the slowness is only due to js files being included in the transformer regex. isolatedModules does not seems to have any issue.
from ts-jest.
I see. Yes in this case Jest will give both js and ts to ts-jest
to transform which explained the issue.
Theoretically if using fast transpiler like swc, it should be better. However, the recommendation is still only transform what is needed.
from ts-jest.
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.
from ts-jest.
I agree, I will update documentation to have a note about this. Thanks for the suggestion!
from ts-jest.
Related Issues (20)
- [Security] Lodash vulnerability
- [Bug]: Cannot read properties of undefined while using NestJS and Enum HOT 1
- [Bug]: error TS2307: Cannot find module '...' or its corresponding type declarations. HOT 2
- [Feature]: Bump JEST to 29.7.0 HOT 3
- [Bug]: docs confusion - deprecated presets HOT 4
- [Bug]: setupFilesAfterEnv with a path to a TS file leads to the error "SyntaxError: Cannot use import statement outside a module" HOT 4
- [Bug]: ESM Support "Use ESM Presets" documentation has confusing redundancy HOT 1
- [Bug]: dynamic imports create a double default-wrapped export -- `{ default: { default: MyDefaultExport } }` HOT 2
- version 29.2.1 and 29.2.2 have new dependency on ejs which is flagged with critical CVE-2023-29827. Can this be remedied? HOT 2
- [Bug]: Using "module": "NodeNext" causes the error "SyntaxError: Cannot use import statement outside a module" HOT 5
- [Bug]: Version `29.2.1` breaks default imports HOT 2
- [Bug]: ts-jest 29.2 breaks dependency transform HOT 18
- [Please read the message below]
- [Bug]: ts-jest[cli] (FATAL) Configuration file jest.config.cjs must be a JavaScript or JSON file. with config.migrate in vite react project HOT 2
- [Please read the message below]
- [Bug]: "ReferenceError: exports is not defined" with ts-jest 29.2 HOT 2
- [Bug]: broken link in installation page in getting started
- [Bug]: When import ESModule from CommonJS, Error: Must use import to load ES Module HOT 12
- [Bug]: Undefined moduleResolution HOT 1
- [Feature]: Support tc39 import attributes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-jest.