Fix for broken renaming of scoped packages #4921
Merged
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.
Summary
I noticed that trying to rename a scoped package fails. After some investigation it turns out the regex in exotics/registry-resolver did not know what to do with scoped packages like "npm:@babel/register", or "npm:@babel/register@7.0.0-beta.32".
I simply had to add an
@?
for the@
right before the name capture group so the@
wouldn't result in everything after it being thrown into the version capture group (leaving name empty). That was the only thing required to get things to work.I've added a test for it to the existing
install renamed packages
test, it seemed to make sense. As test package I used@turf/helpers
since it'd been used as test package in other tests as well.Context: From Babel 7 onwards packages are moved to the @babel scope. I was experimenting with upgrading one of our internal projects to Babel 7. The package
babel-register
is used as an optional peer dependency in other projects (like webpack, for automatically handling config.babel.js) via interpret. By adding @babel/register renamed to babel-register I could use the new version without having to wait for other package authors to update their packages.Test plan
Before this PR:
After: