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

Optimize startup performance #104

Open
sindresorhus opened this issue Nov 6, 2018 · 2 comments
Open

Optimize startup performance #104

sindresorhus opened this issue Nov 6, 2018 · 2 comments

Comments

@sindresorhus
Copy link
Owner

I would like meow to have as little impact on startup performance as possible.

#67 is one way to improve that.

I will also do some profiling with DevTools to see what else can be optimized.

From memory, the

meow/index.js

Line 78 in 646f30b

normalizePackageData(pkg);
is pretty slow, so we could defer normalizing the package.json data until the user calls cli.pkg. We only really need the description field ourselves, which doesn't need to be normalized.

I'm open to other ideas and help with this.

@hugmanrique
Copy link

hugmanrique commented Feb 1, 2020

I've just profiled a really small CLI app that takes ~2 seconds to run using the V8 profiler. This package came up as first for compile time. As you say, the normalizePackageData is the most expensive, because normalize-package-data even parses the license field (using spdx-expression-parse) and parses all URLs with RegExps.

My suggestion would be to avoid reading the package.json if the user passes a pkg: false option, and the --help and --version flags are not present.

@sindresorhus
Copy link
Owner Author

We don’t need the normalize stuff in Meow itself. So we could actually turn it off and only do it on demand if the user accesses the exported .pkg property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants