sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.25k stars 201 forks source link

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

Open oekazuma opened 2 years ago

oekazuma commented 2 years ago

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

dummdidumm commented 2 years ago

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

oekazuma commented 2 years ago

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.

Tal500 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

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?

FredrikAugust commented 2 months ago

Any updates on this?