Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The way this plugin works currently is that for every invocation of
parse
by Prettier we:However, in plugins like Svelte or Vue that handle mixed languages,
parse
is called for every single JS or TypeScript expression. When there's a lot of them all of the above happens once for every single expression in a Svelte or Vue file 😱. Doing this once or twice total isn't a big deal — but if your file has hundreds of expressions, dynamic attributes, etc… this time adds up.With this change we now do this at most once per source file per 5s interval (this is subject to change). The time interval lets us handle changes to the Tailwind CSS config without performing expensive operations like object hashing while also caching the config and everything associated with it.
When plugins are involved the time and memory savings can be fairly significant. I've seen the time drop from 15s to 3.5s for a Svelte file with 1,000 expressions (around 3s of that is the baseline with just the Svelte plugin). The memory savings in that case dropped from 3.5GB across 3 files to around 350-ish MB.
Fixes #148
This might also fix the issues people have seen in Vue and Next projects but not yet 100% certain.