Skip to content

Add cache for known plugins#301

Merged
thecrypticace merged 3 commits into
mainfrom
feat/resolve-cache
Jun 29, 2024
Merged

Add cache for known plugins#301
thecrypticace merged 3 commits into
mainfrom
feat/resolve-cache

Conversation

@thecrypticace

Copy link
Copy Markdown
Contributor

We have to call require.resolve(…) ~10 times per call to parse(…). These calls generally take microseconds however if you call prettier.format(…) several thousand times the times add up. It also adds up for embedded documents which call parse(…) a large number of times.

This PR adds a cache for these calls because generally only a few will ever be installed and Node.js will not cache misses internally.

We have to call `require.resolve(…)` ~10 times per call to `parse(…)`. These calls generally take microseconds however if you call `prettier.format(…)` several thousand times the times add up. It also adds up for embedded documents which call `parse(…)` a large number of times.

This adds a cache for these calls because generally only a few will ever be installed and Node.js will not cache misses internally.
Comment thread src/config.ts
Comment thread src/plugins.ts Outdated
Comment thread src/resolve.ts
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
@thecrypticace thecrypticace merged commit ee50b9b into main Jun 29, 2024
@thecrypticace thecrypticace deleted the feat/resolve-cache branch June 29, 2024 13:40
bronisMateusz pushed a commit to bronisMateusz/prettier-plugin-tailwindcss-drupal that referenced this pull request Apr 16, 2025
* Add cache for known plugins

We have to call `require.resolve(…)` ~10 times per call to `parse(…)`. These calls generally take microseconds however if you call `prettier.format(…)` several thousand times the times add up. It also adds up for embedded documents which call `parse(…)` a large number of times.

This adds a cache for these calls because generally only a few will ever be installed and Node.js will not cache misses internally.

* Update src/plugins.ts

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>

* Update changelog

---------

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
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

Successfully merging this pull request may close these issues.

2 participants