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

Very slow as soon as "coffescript" package is installed #988

Open
neelance opened this issue Mar 23, 2025 · 1 comment
Open

Very slow as soon as "coffescript" package is installed #988

neelance opened this issue Mar 23, 2025 · 1 comment

Comments

@neelance
Copy link
Contributor

On our codebase (with a simplified config), depcruiser takes 7 seconds to complete. As soon as the "coffeescript" package is installed, it takes 40 seconds instead.

I understand that automatically using the transpiler if it is installed is an intended feature. However, this performance behaviour is surprising and not easy to debug. It took a while for me to pinpoint "coffeescript" as the culprit.

I see a several options to improve this:

  • Print a warning if the CoffeeScript transpiler is used and there are many .js files
  • Print a warning if the CoffeeScript transpiler is used and there are no .coffee files
  • Do not use the CoffeeScript transpiler if there are no .coffee files
  • Make the CoffeeScript transpiler opt-in in the config
@sverweij
Copy link
Owner

Hi @neelance (sorry for the slow response - private life takes a bit more time than previously at the moment).

I can think of two things within the program that'd explain slower execution with the mere pressence of the coffeescript compiler:

  • At start-up time it will try to load the coffeescript compiler. This will make dependency-cruiser's startup time a bit slower (on my local machine it's 10ms). I don't think that's the culprit here.
  • During module resolution - dependency-cruiser by default configures the resolver to go through the list of extensions it has a compiler for available, until it finds a hit. If there's a few modules that can't be resolved to disk at all, the resolver will run through the entire list - which will be noticeable in its run time, especially so for coffeescript as it supports a whopping 6 extra extensions to try out. From your description this seems what is happening.
  • depcruise --info will show you the compilers dependency-cruiser found as well as the list of extensions it (as a consequence) supports (and hence scans) by default.

A potential fix/ workaround:

With the enhancedResolveOptions.extensions option you can curb this (safe but potentially slow) default behavior by limiting the extensions it scans. This is also what depcruise --init will attempt when it scaffolds a .dependency-cruiser.js - it scans the contents of your source folder and set up the extensions property to those it found there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants