Skip to content

feat: use Yarn v3 with nodeLinker: node-modules for new projects - #2134

Merged
thymikee merged 7 commits into
mainfrom
feat/use-yarn-3-in-init
Jan 3, 2024
Merged

feat: use Yarn v3 with nodeLinker: node-modules for new projects#2134
thymikee merged 7 commits into
mainfrom
feat/use-yarn-3-in-init

Conversation

@szymonrybczak

@szymonrybczakszymonrybczak commented Oct 26, 2023

Copy link
Copy Markdown
Collaborator

Summary:

Closes#1931

When creating new project we'll try to bump Yarn version to v3. We'll only do this if:

  • the project is initialised in fresh environment (not in existing Git repo),
  • and the Yarn version in the location is Yarn Classicbc8aaaa

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Run this command:
node /path/to/react-native-cli/packages/cli/build/bin.js init
  1. Should use Yarn v3 🎉

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@szymonrybczak

Copy link
Copy Markdown
CollaboratorAuthor

@tido64@satya164 I would really appreciate your review 🙏

@szymonrybczak
szymonrybczakforce-pushed the feat/use-yarn-3-in-init branch 2 times, most recently from 9afaa54 to 4457c77CompareOctober 26, 2023 18:38
@szymonrybczak

Copy link
Copy Markdown
CollaboratorAuthor

One note here is that Yarn v4 was released few days ago, and it is working with React Native properly. With this change we're aiming for 0.74 so until that time it will be tested well in various production environments. Also Yarn v4 had 53 releases so we can assume that team tested it well 😅 So let''s wait for some minor fixes that probably will be released, and then will finally bump to Yarn v4 in CLI - with current setup it is just changing number.

@szymonrybczak
szymonrybczakforce-pushed the feat/use-yarn-3-in-init branch 2 times, most recently from c3bbbb5 to b9fb423CompareOctober 26, 2023 20:10
Comment threadpackages/cli/src/tools/packageManager.ts Outdated

@tido64tido64 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@robhoganrobhogan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Couple of questions/suggestions but LGTM in principle

Comment threadjest/helpers.ts Outdated
Comment threadpackages/cli/src/commands/init/init.ts
Comment on lines +67 to +85
await executeCommand('yarn', ['set', 'version', YARN_VERSION], {
root,
silent,
});

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just to check my understanding here - this will install the requested version via corepack if it isn't currently on the machine? What if corepack isn't enabled?

@szymonrybczak
szymonrybczakforce-pushed the feat/use-yarn-3-in-init branch 2 times, most recently from a8af0aa to 1b47345CompareNovember 2, 2023 09:24
Comment threadpackages/cli/src/commands/init/init.ts
Comment threadpackages/cli/src/commands/init/init.ts Outdated
@szymonrybczak
szymonrybczakforce-pushed the feat/use-yarn-3-in-init branch 3 times, most recently from 667da6d to bc0dc7dCompareNovember 6, 2023 21:12

@EsemesekEsemesek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems to be working fine on my machine. Code also seems to be LGTMT +1

@szymonrybczak
szymonrybczakforce-pushed the feat/use-yarn-3-in-init branch from 8f96a0e to fac59f2CompareJanuary 2, 2024 17:17
@thymikee
thymikee merged commit f22be6d into mainJan 3, 2024
@thymikee
thymikee deleted the feat/use-yarn-3-in-init branch January 3, 2024 15:21
facebook-github-bot pushed a commit to react/react-native that referenced this pull request Jan 19, 2024
Summary:
Recently inside React Native Community CLI we added bumping Yarn version inside `init` command, more information here: react-native-community/cli#2134. In this Pull Request I added required rules in `.gitignore` for new projects created.
## Changelog:
[GENERAL] [ADDED] - Add Yarn files to `.gitignore` in template
Pull Request resolved: #42313
Test Plan:
1. Follow [Contributing guide](https://github.com/react-native-community/cli/blob/main/CONTRIBUTING.md) from React Native Community CLI repository to setup locally newest version of CLI.
2. Run this command:
```sh
node /path/to/react-native-cli/packages/cli/build/bin.js init --template path/to/template
```
3. Appropriate should be ignored.
Reviewed By: NickGerleman
Differential Revision: D52907962
Pulled By: cortinico
fbshipit-source-id: f12dce8836e7e94257f8c690434b11227aa46446
blakef pushed a commit to blakef/template that referenced this pull request Feb 28, 2024
Summary:
Recently inside React Native Community CLI we added bumping Yarn version inside `init` command, more information here: react-native-community/cli#2134. In this Pull Request I added required rules in `.gitignore` for new projects created.
## Changelog:
[GENERAL] [ADDED] - Add Yarn files to `.gitignore` in template
Pull Request resolved: react/react-native#42313
Test Plan:
1. Follow [Contributing guide](https://github.com/react-native-community/cli/blob/main/CONTRIBUTING.md) from React Native Community CLI repository to setup locally newest version of CLI.
2. Run this command:
```sh
node /path/to/react-native-cli/packages/cli/build/bin.js init --template path/to/template
```
3. Appropriate should be ignored.
Reviewed By: NickGerleman
Differential Revision: D52907962
Pulled By: cortinico
fbshipit-source-id: f12dce8836e7e94257f8c690434b11227aa46446
Original: react/react-native@965f2eb
blakef pushed a commit to react-native-community/template that referenced this pull request Feb 29, 2024
Summary:
Recently inside React Native Community CLI we added bumping Yarn version inside `init` command, more information here: react-native-community/cli#2134. In this Pull Request I added required rules in `.gitignore` for new projects created.
## Changelog:
[GENERAL] [ADDED] - Add Yarn files to `.gitignore` in template
Pull Request resolved: react/react-native#42313
Test Plan:
1. Follow [Contributing guide](https://github.com/react-native-community/cli/blob/main/CONTRIBUTING.md) from React Native Community CLI repository to setup locally newest version of CLI.
2. Run this command:
```sh
node /path/to/react-native-cli/packages/cli/build/bin.js init --template path/to/template
```
3. Appropriate should be ignored.
Reviewed By: NickGerleman
Differential Revision: D52907962
Pulled By: cortinico
fbshipit-source-id: f12dce8836e7e94257f8c690434b11227aa46446
Original-Commit: react/react-native@965f2eb
blakef pushed a commit to react-native-community/template that referenced this pull request Feb 29, 2024
Summary:
Recently inside React Native Community CLI we added bumping Yarn version inside `init` command, more information here: react-native-community/cli#2134. In this Pull Request I added required rules in `.gitignore` for new projects created.
## Changelog:
[GENERAL] [ADDED] - Add Yarn files to `.gitignore` in template
Pull Request resolved: react/react-native#42313
Test Plan:
1. Follow [Contributing guide](https://github.com/react-native-community/cli/blob/main/CONTRIBUTING.md) from React Native Community CLI repository to setup locally newest version of CLI.
2. Run this command:
```sh
node /path/to/react-native-cli/packages/cli/build/bin.js init --template path/to/template
```
3. Appropriate should be ignored.
Reviewed By: NickGerleman
Differential Revision: D52907962
Pulled By: cortinico
fbshipit-source-id: f12dce8836e7e94257f8c690434b11227aa46446
Original-Commit: react/react-native@965f2eb
@noway

Copy link
Copy Markdown

Sorry if this is not the right forum or if this is too much of a qualitative judgement, but I'd like to share my thoughts.

Yarn Modern is less popular than Yarn Classic. While Yarn Classic is deprecated (and to be fair, subtly broken in different ways), Yarn Modern hasn't shown enough resiliency and it's long term success is far from guaranteed.

Forcing new projects to start with Yarn v3 may send them on a path where they may end up with an unmaintained package manager few years down the track.

Is it a prudent decision to switch new projects to Yarn Modern, especially for users who are just starting out with React Native? NPM would be a much sure choice.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@szymonrybczak@noway@satya164@robhogan@tido64@Esemesek@thymikee