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

ts-jest with cleared cache is reading package.json in node_modules over and over - start takes forever #16703

Closed
Farbdose opened this issue Dec 12, 2018 · 8 comments
Labels
package: angular @ionic/angular package

Comments

@Farbdose
Copy link

Farbdose commented Dec 12, 2018

Bug Report

I just updated to ts-jest@23.10.5 from somewhere around ~23.1.3 which increased the runtime of my test suite from 10ish seconds [on the first run / with cleared cache] to over 40 seconds - with cache around 2.5s.

It's possible that this is a ts-jest (or even typescript) issue BUT after I created a demo-repository I realized that the problem went away after I removed ionic from the project.
So ionic probably has something to do with it.

Ionic version:

[x] 4.x

Current behavior:
The initial start of jest takes around 30 seconds on an almost empty repository with ionic included.

Expected behavior:
The initial start of jest shouldn't take that long.

Steps to reproduce:

  • Have js files that need to be processed by ts-jest (as they contain import statements) being present in one of the modules you import
  • have ts-jest@>=23.10.1
  • import the IonicModule in one of you angular modules

Related code:
https://gitlab.com/Farbdose/ts-jest-multiple-fileread

git clone git@gitlab.com:Farbdose/ts-jest-multiple-fileread.git
npm install && npm run test

Other information:

You can find the original issue at kulshekhar/ts-jest#908
Possibly related #15695: I had to use the fix described there to actually get jest running at all.

Ionic info:

[WARN] You are not in an Ionic project directory. Project context may be missing.

Ionic:

   ionic (Ionic CLI) : 4.3.1

System:

   NodeJS : v8.11.2
   npm    : 6.1.0
   OS     : Linux 4.15
@Farbdose
Copy link
Author

Farbdose commented Dec 18, 2018

Update: I played a bit around and wrote a very basic [destructive] cache into getPackageJsonInfo see here ...which got the time down to around 24s again.

The interesting thing though is, that after that I got a much clearer cpu profile:
CPU-20181218T162138.zip

@Farbdose
Copy link
Author

Update2: I updated the demo repository to ionic 4.0.0-rc.0 and typescript to 3.2.2.

It now takes around 45 seconds in the gitlab build pipeline so if anybody wants to try his luck, you are welcome.

@Farbdose
Copy link
Author

Farbdose commented Jan 9, 2019

Update3: @paulstelzer This was caused by a combination of uncached file reads and now by default enabled language services in ts-jest. It has nothing to do with ionic, ionic was just the package with the most require-statements / separate modules in node_modules.

@paulstelzer
Copy link
Contributor

so this can be closed now?

@Farbdose
Copy link
Author

Farbdose commented Jan 9, 2019

@paulstelzer yes

@paulstelzer
Copy link
Contributor

Thank you for the resarch :)

@Farbdose
Copy link
Author

Farbdose commented Jan 9, 2019

@paulstelzer I think the only thing you could have realistically done is what you alread did: remove the icons from the build chain. ts-jest was probably reading the package.json again and again for each icon...

@ionitron-bot
Copy link

ionitron-bot bot commented Feb 8, 2019

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: angular @ionic/angular package
Projects
None yet
Development

No branches or pull requests

2 participants