Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Idea #397

Open
stefanpenner opened this issue Dec 16, 2021 · 0 comments
Open

Performance Idea #397

stefanpenner opened this issue Dec 16, 2021 · 0 comments

Comments

@stefanpenner
Copy link

stefanpenner commented Dec 16, 2021

This is a cool project!

I was curious how this project approached various scenarios, after doing so I believe I can share some past findings and alternative approaches that may be of use to you.

Specifically finding package.json's recursively across a large dep graph with duplicates can easily consume a large amount of time (in some of our applications this alone could take many minutes) (although our approach did traverse node_modules, which amplifies this problem)

The existing approach ->

const packageRoot = await findUp("package.json", { cwd });

To mitigate this problem, some collaborators and I implemented a pretty fast approach that worked well for our use cases ultimately turning those minutes into seconds in the largest of our applications.

Our approach does the following:

  • carefully avoids unnecessary IO
  • added various levels of memoization, which by default mimics that of nodes require but is configurable to suit most use cases.

When profiling slow builds, we noticed many such problems and ended up extracting our approach for reuse. If you are interested, it can be found here -> https://github.com/stefanpenner/resolve-package-path

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

No branches or pull requests

1 participant