Skip to content

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

Closed

Description

@Farbdose

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

Activity

  1. Farbdose commented on Dec 18, 2018

    @Farbdose
    Author

    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

  2. Farbdose commented on Dec 20, 2018

    @Farbdose
    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.

  3. Farbdose commented on Jan 9, 2019

    @Farbdose
    Author

    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.

  4. paulstelzer commented on Jan 9, 2019

    @paulstelzer
    Contributor

    so this can be closed now?

  5. Farbdose commented on Jan 9, 2019

    @Farbdose
    Author
  6. paulstelzer commented on Jan 9, 2019

    @paulstelzer
    Contributor

    Thank you for the resarch :)

  7. Farbdose commented on Jan 9, 2019

    @Farbdose
    Author

    @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...

  8. ionitron-bot commented on Feb 8, 2019

    @ionitron-bot

    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.

  9. locked and limited conversation to collaborators on Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions