Skip to content

Conversation

@thecrypticace
Copy link
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.
Co-authored-by: Robin Malfait <[email protected]>
@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 <[email protected]>

* Update changelog

---------

Co-authored-by: Robin Malfait <[email protected]>
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.

3 participants