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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve linked packages in create command #7543

Merged

Conversation

nickmccurdy
Copy link
Contributor

@nickmccurdy nickmccurdy commented Sep 11, 2019

Summary

Currently, yarn create does not respect an existing package linked with yarn link, and will instead overwrite the package in development with the latest version from the registry. With this fix, the package will only be installed if it isn't already linked, allowing users to use yarn create to develop locally linked packages without removing their global link. This matches the functionality of npm init and npm create with linked packages.

Test plan

Fixed test cases

Package is linked

Package is not installed globally and linked聽package is used instead

$ cd PACKAGE_SOURCE
$ yarn link
yarn global v1.18.0-0
success Registered "PACKAGE".
info You can now run `yarn link "PACKAGE"` in the projects where you want to use this package and it will be used instead.
$ yarn create PACKAGE_SUFFIX --version
yarn create v1.18.0-0
LINKED_VERSION

Unchanged test cases

Package is not linked or installed

Package is installed globally before running the command

$ yarn create PACKAGE_SUFFIX --version
yarn global v1.18.0-0
[1/4] 馃攳  Resolving packages...
[2/4] 馃殮  Fetching packages...
[3/4] 馃敆  Linking dependencies...
[4/4] 馃敤  Building fresh packages...

success Installed "PACKAGE@PUBLISHED_VERSION" with binaries:
      - COMMAND
PUBLISHED_VERSION

Package is installed

Package is reinstalled globally (which may update it) before running the command

$ yarn global add PACKAGE
yarn global v1.18.0-0
[1/4] 馃攳  Resolving packages...
[2/4] 馃殮  Fetching packages...
[3/4] 馃敆  Linking dependencies...
[4/4] 馃敤  Building fresh packages...
success Installed "PACKAGE@PUBLISHED_VERSION" with binaries:
      - COMMAND
$ yarn create PACKAGE_SUFFIX --version
yarn create v1.18.0-0
[1/4] 馃攳  Resolving packages...
[2/4] 馃殮  Fetching packages...
[3/4] 馃敆  Linking dependencies...
[4/4] 馃敤  Building fresh packages...
success Installed "PACKAGE@PUBLISHED_VERSION" with binaries:
      - COMMAND
PUBLISHED_VERSION

@buildsize
Copy link

buildsize bot commented Sep 11, 2019

File name Previous Size New Size Change
yarn-[version].noarch.rpm 1.18聽MB 1.18聽MB -11聽bytes (0%)
yarn-[version].js 4.85聽MB 4.85聽MB 287聽bytes (0%)
yarn-legacy-[version].js 5.05聽MB 5.05聽MB 284聽bytes (0%)
yarn-v[version].tar.gz 1.18聽MB 1.19聽MB 1.88聽KB (0%)
yarn_[version]all.deb 868.77聽KB 868.67聽KB -100聽bytes (0%)

@nickmccurdy

This comment has been minimized.

@nickmccurdy

This comment has been minimized.

@nickmccurdy
Copy link
Contributor Author

Updated to display info Using linked package for "PACKAGE". when the linked package is used.

@arcanis arcanis merged commit 1bdb15a into yarnpkg:master Sep 18, 2019
@arcanis
Copy link
Member

arcanis commented Sep 18, 2019

Thanks! 馃檪

@nickmccurdy
Copy link
Contributor Author

Thanks again for your help!

VincentBailly pushed a commit to VincentBailly/yarn that referenced this pull request Jun 10, 2020
* Preserve linked packages in create command

* Update changelog

* Warn when using linked package

* Update CHANGELOG.md

* Update link-resolver.js
VincentBailly pushed a commit to VincentBailly/yarn that referenced this pull request Jun 10, 2020
* Preserve linked packages in create command

* Update changelog

* Warn when using linked package

* Update CHANGELOG.md

* Update link-resolver.js
@nickmccurdy nickmccurdy deleted the preserve-linked-packages-in-create-command branch September 14, 2022 16:16
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.

None yet

2 participants