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

fix(perf): do less work loading config #7361

Merged
merged 2 commits into from
Apr 10, 2024
Merged

fix(perf): do less work loading config #7361

merged 2 commits into from
Apr 10, 2024

Conversation

wraithgar
Copy link
Member

This adds some lazy loading, inlines some single use functions, and also
removes the "define" function in the definitions file. That was
guarding against something that isn't worth the runtime to check for.

@wraithgar
Copy link
Member Author

wraithgar commented Apr 10, 2024

Draft because this won't automatically run the npm tests. I will do that locally to make sure nothing broke there.

npm tests fixed, added a config test to make sure we keep the definitions sorted (will help guard against the one thing define() was doing)

@@ -695,6 +687,7 @@ class Config {
}

if (this.localPrefix && hasPackageJson) {
const rpj = require('read-package-json-fast')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use none of the normalization here, we should consider using the underlying JSON parser in this situation.


const semver = require('semver')
class Umask {}
class Semver {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@H4ad the class is meaningless it's just a unique "object" to hang nopt definitions off of. I opted for the same as Umask here instead. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't matter, I think it's okay.

I'd rather have our own version than import from semver, even though the import time from classes/semver is being measured in us.

@wraithgar wraithgar marked this pull request as ready for review April 10, 2024 14:47
@wraithgar wraithgar requested a review from a team as a code owner April 10, 2024 14:47
@wraithgar wraithgar merged commit 3760dd2 into latest Apr 10, 2024
36 checks passed
@wraithgar wraithgar deleted the gar/config-perf branch April 10, 2024 17:19
@github-actions github-actions bot mentioned this pull request Apr 10, 2024
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