TypeScript compilation slower than tsc command

Hi,

We have a Strapi project containing a mix of JS and TS files (migration in progress). We recently upgraded Strapi from 4.11.x to 4.20.x. Compilation + start time are getting very slow. We had already to wait about 8 seconds. Now it’s up to 20 seconds with the new version.

This makes me wonder: why is Strapi so slow compiling TS? Which mechanisms create this problem?

Using the command line ./node_modules/.bin/tsc --watch the first compilation last 3 seconds, and the following are bellow 500ms.

Now with strapi develop, I always get: :heavy_check_mark: Compiling TS (5009ms)

System Information
  • Strapi Version: 4.20
  • Operating System: MacOs
  • Database: PG
  • Node Version: 20.x
  • NPM Version:
  • Yarn Version:

In case someone is facing the same issue, I found this workaround:

tsc-watch --onSuccess "npm run start"

Just needs 2 seconds to recompile and relaunch Strapi afteward.

See more: GitHub - gilamran/tsc-watch: The TypeScript compiler with --watch and a new onSuccess argument