Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
small optimization #7176
small optimization #7176
Changes from 1 commit
6977f89
f5d35fe
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We tend not to do this as it unnecessarily couples to the layout of the code, and not its exports.
module.exports
is the module, as far a our semver conventions are concerned. This allows us to completely refactor or rewrite a module and not make it a breaking change, as long as the exports are the same.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The layout of internal files is already part of the api and subject to semver, unless the exports field is used to encapsulate them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that the future refactor does not introduce destructive changes
I suggest adding an export field to the package.json of this module, will this solve this problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like that would have to be a larger decision/discussion than just one repo, it falls under how we build all of our software. Currently we define a
main
entry .e.g. https://github.com/npm/npm-registry-fetch/blob/e58e8bc6c5b25d53a764f58190fc3a5c764a2e78/package.json#L5, and rely onmodule.exports
to define the api.exports
is an alternative tomain
, not a replacement. We are not moving toexports
right now so my original, single-line suggestion is all we really want to do right now.The line as it is now was done very intentionally, and adding that function to
module.exports
was the way in which it was exported.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, you suggest leaving
require('npm-registry-fetch')
even though it adds ~15% to the runtimeIf the only problem is that you are just starting to migrate to declaring
exports
inpackage.json
, then I could first send a PR tonpm-registry-fetch
so that I can painlessly import onlycleanUrl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes leave it. A pr to
npm-registry-fetch
would be rejected as we would want to centrally manage that entry in package.json from@npmcli/template-oss
and enforce it on ALL our packages.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
38 milliseconds (15% of 256) for
npm run
is not something we need to hyper optimize. This is not a hot path like reification.