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 for broken renaming of scoped packages #4921

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

Ambroos
Copy link
Contributor

@Ambroos Ambroos commented Nov 14, 2017

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:

Ambroos@Mac:~/Dev/temp $ yarn add --dev babel-register@npm:@babel/register@7.0.0-beta.32
yarn add v1.3.2
info No lockfile found.
[1/4] 🔍  Resolving packages...
error Received malformed response from registry for undefined. The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

After:

Ambroos@Mac:~/Dev/temp $ alias yarn="node ~/Dev/yarn/lib/cli/index.js"
Ambroos@Mac:~/Dev/temp $ yarn add --dev babel-register@npm:@babel/register@7.0.0-beta.32
yarn add v1.3.2
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning " > babel-register@7.0.0-beta.32" has unmet peer dependency "@babel/core@7.0.0-beta.32".
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 20 new dependencies.
├─ babel-register@7.0.0-beta.32
...
└─ source-map@0.5.7
✨  Done in 1.56s.
Ambroos@Mac:~/Dev/player/temp $```

@Ambroos
Copy link
Contributor Author

Ambroos commented Nov 15, 2017

There seems to have been a problem with the test runners, as the tests should all pass. I can't rerun tests and don't want to make unnecessary changes. Could someone re-run them?

@waleedahmed3045
Copy link

Can the builds be triggered again for this PR? As it was a circleci issue.
image

https://discuss.circleci.com/t/unable-to-spin-up-environment/18109

@Ambroos Ambroos force-pushed the fix-renaming-scoped-packages branch from a8405e4 to 8d1032b Compare March 13, 2018 18:09
@Ambroos
Copy link
Contributor Author

Ambroos commented Mar 13, 2018

I have rebased my work on master, tests seem to be (mostly) OK now.

@Gudahtt
Copy link
Member

Gudahtt commented Aug 15, 2018

It looks like this has been fixed already, in this PR: #5229

@Gudahtt Gudahtt force-pushed the fix-renaming-scoped-packages branch from 8d1032b to e82dc8c Compare October 9, 2018 14:28
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

While this was fixed elsewhere, the additional integration test certainly couldn't hurt. The other PR had unit tests, but no integration test.

@Gudahtt Gudahtt merged commit 86888e1 into yarnpkg:master Oct 10, 2018
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