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

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

Merged
merged 7 commits into from
Jan 3, 2024

Conversation

szymonrybczak
Copy link
Collaborator

@szymonrybczak szymonrybczak commented Oct 26, 2023

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 Classic bc8aaaa

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
Collaborator Author

@tido64 @satya164 I would really appreciate your review 🙏

@szymonrybczak szymonrybczak force-pushed the feat/use-yarn-3-in-init branch 2 times, most recently from 9afaa54 to 4457c77 Compare October 26, 2023 18:38
@szymonrybczak
Copy link
Collaborator Author

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 szymonrybczak force-pushed the feat/use-yarn-3-in-init branch 2 times, most recently from c3bbbb5 to b9fb423 Compare October 26, 2023 20:10
Copy link
Contributor

@tido64 tido64 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@robhogan robhogan left a comment

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

jest/helpers.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/init/init.ts Show resolved Hide resolved
Comment on lines +67 to +85
await executeCommand('yarn', ['set', 'version', YARN_VERSION], {
root,
silent,
});
Copy link
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 szymonrybczak force-pushed the feat/use-yarn-3-in-init branch 2 times, most recently from a8af0aa to 1b47345 Compare November 2, 2023 09:24
packages/cli/src/commands/init/init.ts Show resolved Hide resolved
packages/cli/src/commands/init/init.ts Outdated Show resolved Hide resolved
@szymonrybczak szymonrybczak force-pushed the feat/use-yarn-3-in-init branch 3 times, most recently from 667da6d to bc0dc7d Compare November 6, 2023 21:12
Copy link
Member

@Esemesek Esemesek left a comment

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

@thymikee thymikee merged commit f22be6d into main Jan 3, 2024
10 checks passed
@thymikee thymikee deleted the feat/use-yarn-3-in-init branch January 3, 2024 15:21
facebook-github-bot pushed a commit to facebook/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: facebook/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: facebook/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: facebook/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: facebook/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: facebook/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: facebook/react-native@965f2eb
@noway
Copy link

noway commented Apr 22, 2024

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 free to 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