Sitelet https://github.com/yarnpkg/yarn/pull/7543
Skip to content

Preserve linked packages in create command - #7543

Merged
arcanis merged 5 commits into
yarnpkg:masterfrom
nickserv:preserve-linked-packages-in-create-command
Sep 18, 2019
Merged

arcanis merged 5 commits into
yarnpkg:masterfrom
nickserv:preserve-linked-packages-in-create-command

Conversation

@nickserv

@nickserv nickserv commented Sep 11, 2019 •

Copy link
Copy Markdown
Contributor

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

buildsize Bot commented Sep 11, 2019 •

Copy link
Copy Markdown
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%)

@nickserv

This comment has been minimized.

@nickserv

This comment has been minimized.

@nickserv

Copy link
Copy Markdown
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

arcanis commented Sep 18, 2019

Copy link
Copy Markdown
Member

Thanks! 🙂

@nickserv

Copy link
Copy Markdown
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
@nickserv
nickserv 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.

2 participants