language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Add `--cache` CLI option to svelte-check

Open oekazuma opened this issue 2 years ago • 5 comments

Description

I use githooks to run ESLint, Prettier, and svelte-check at the same time as commit. ESLint and Prettier are fast because they keep a cache, but svelte-check is slow if run every time.

Proposed solution

That when provided with an option such as --cache, svelte-check only process new or changed files. With reference to ESLint and Prettier.

Alternatives

No response

Additional Information, eg. Screenshots

No response

oekazuma avatar Jun 27 '22 02:06 oekazuma

We can't check changed files only because a change in file A could introduce errors in unchanged file B (if you change a prop name for example). Only thing we can do is to check if we can leverage some of the incremental build features of tsc to at least save time in the program creating time

dummdidumm avatar Jun 27 '22 06:06 dummdidumm

I think you are right. I understand that this is not simply an ESLint or Prettier approach.

If you think that faster execution can be addressed in another issue, you are free to close this issue.

oekazuma avatar Jun 27 '22 06:06 oekazuma

I think you are right. I understand that this is not simply an ESLint or Prettier approach.

If you think that faster execution can be addressed in another issue, you are free to close this issue.

It's also related to the issue I've just posted now #1584 .

Tal500 avatar Aug 12 '22 15:08 Tal500

We can't check changed files only because a change in file A could introduce errors in unchanged file B (if you change a prop name for example). Only thing we can do is to check if we can leverage some of the incremental build features of tsc to at least save time in the program creating time

You don't have to rely on incremental build features of tsc. (I hope) You can also ask tsc to map you the dependency graph of the files, and then rescan only the affected files.

Tal500 avatar Aug 12 '22 15:08 Tal500

@dummdidumm , I have found a library that calculate dependency graph for your code: sverweij/dependency-cruiser.

What do you think about the idea (of I already mentioned) - instead of having a full caching compatibility, let just cache:

  • hashes of input files
  • generate a dependency graph (e.g. by the library I mentioned)

Then, on the next time Svelte Preprocess runs, you can check the file hashes, and for the files that were changed, using the cached dependency graph, check only the relevant files.

Did I miss something? What do you think?

Tal500 avatar Aug 26 '22 15:08 Tal500