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

chore: Upgrade to Yarn 3 #604

Merged
merged 19 commits into from
Sep 7, 2022
Merged

Conversation

tschaffter
Copy link
Member

@tschaffter tschaffter commented Aug 23, 2022

Notes

  • This PR upgrades the development environment to Yarn 2+ ("Yarn Berry").
  • Yarn 2+ introduces lock file format v2.
    • Look similar to v1 but best to regenerate the lock file with Yarn 2+ if possible.
  • Motivations and performance benchmarks
  • Yarn 3 CLI is almost identical to Yarn 1 CLI.
    • The only difference relevant to our project is:
      • yarn install --frozen-lockfile is replaced by yarn install --immutable
      • yarn bin is not longer displaying the path to the local node_modules/.bin folder (used in dev-env.sh).

Testing

  1. Checkout this branch.
  2. Rebuild the dev container.
  3. Remove the existing node_modules.
  4. Install the Node.js dependencies: challenge-install.
  5. Start the challenge registry: nx serve challenge-registry.
  6. Check that the registry loads successfully in the browser.

Note
Repeat Steps 3-4 when returning to a branch that uses Yarn 1.

TODO before merging

  • Replace dev container image tag by whatever value is used in main.

@tschaffter tschaffter self-assigned this Aug 23, 2022
@tschaffter tschaffter marked this pull request as draft August 23, 2022 17:16
@tschaffter tschaffter changed the title chore: Upgrade to yarn 3 chore: Upgrade to Yarn 3 Aug 23, 2022
@tschaffter
Copy link
Member Author

tschaffter commented Aug 24, 2022

Yarn messes up $PATH

$ echo $PATH
/vscode/vscode-server/bin/linux-x64/e4503b30fc78200f846c62cf8091b76ff5547662/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:➤ YN0000: ng ➤ YN0000: nx-cloud ➤ YN0000: openapi-generator-cli ➤ YN0000: openapi ➤ YN0000: coveralls ➤ YN0000: cypress ➤ YN0000: eslint ➤ YN0000: hint ➤ YN0000: husky ➤ YN0000: lint-openapi ➤ YN0000: prettier ➤ YN0000: redoc-cli ➤ YN0000: shx ➤ YN0000: tsc ➤ YN0000: tsserver ➤ YN0000: ng-xi18n ➤ YN0000: ngc ➤ YN0000: ngcc ➤ YN0000: eslint-config-prettier ➤ YN0000: jest ➤ YN0000: ng-packagr ➤ YN0000: nx ➤ YN0000: ts-jest ➤ YN0000: ts-node ➤ YN0000: ts-node-cwd ➤ YN0000: ts-node-esm ➤ YN0000: ts-node-script ➤ YN0000: ts-node-transpile-only ➤ YN0000: ts-script ➤ YN0000: Done in 0s 55ms

Here is the path in the dev container used in the main branch:

vscode@b9fbf54728dd:/workspaces/challenge-registry$ echo $PATH
/vscode/vscode-server/bin/linux-x64/e4503b30fc78200f846c62cf8091b76ff5547662/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workspaces/challenge-registry/node_modules/.bin

The issue occurs when sourcing dev-env.sh.

vscode@ac5a8a1b4f30:/workspaces/challenge-registry$ echo $PATH
/vscode/vscode-server/bin/linux-x64/e4503b30fc78200f846c62cf8091b76ff5547662/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workspaces/challenge-registry/node_modules/.bin
vscode@ac5a8a1b4f30:/workspaces/challenge-registry$ nx --version
14.5.4
vscode@ac5a8a1b4f30:/workspaces/challenge-registry$ git branch
  connect-app-and-backend
  doc-linter-formatter
  document-stack-components
  explore-dvc
  gradle-unit-integration
  main
* test-yarn3
vscode@ac5a8a1b4f30:/workspaces/challenge-registry$ . ./dev-env.sh 
vscode@ac5a8a1b4f30:/workspaces/challenge-registry$ echo $PATH
/vscode/vscode-server/bin/linux-x64/e4503b30fc78200f846c62cf8091b76ff5547662/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/workspaces/challenge-registry/node_modules/.bin:➤ YN0000: ng ➤ YN0000: nx-cloud ➤ YN0000: openapi-generator-cli ➤ YN0000: openapi ➤ YN0000: coveralls ➤ YN0000: cypress ➤ YN0000: eslint ➤ YN0000: hint ➤ YN0000: husky ➤ YN0000: lint-openapi ➤ YN0000: prettier ➤ YN0000: redoc-cli ➤ YN0000: shx ➤ YN0000: tsc ➤ YN0000: tsserver ➤ YN0000: ng-xi18n ➤ YN0000: ngc ➤ YN0000: ngcc ➤ YN0000: eslint-config-prettier ➤ YN0000: jest ➤ YN0000: ng-packagr ➤ YN0000: nx ➤ YN0000: ts-jest ➤ YN0000: ts-node ➤ YN0000: ts-node-cwd ➤ YN0000: ts-node-esm ➤ YN0000: ts-node-script ➤ YN0000: ts-node-transpile-only ➤ YN0000: ts-script ➤ YN0000: Done in 0s 46ms

Fixed

@tschaffter tschaffter marked this pull request as ready for review August 24, 2022 19:29
@tschaffter
Copy link
Member Author

@rrchai Would you have time to review this PR before our next dev workshop (September 2nd)?

@tschaffter
Copy link
Member Author

@rrchai This PR can be tested despite the conflict with yarn.lock shown above. The lock file that comes with this PR (generated with Yarn 3) is different from the lock file in main (generated with Yarn 1).

Copy link
Contributor

@rrchai rrchai left a comment

Choose a reason for hiding this comment

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

Thanks for upgrading yarn. I like the colors here during the challenge-install:

Screen Shot 2022-09-01 at 9 59 43 PM

I can reproduce similar running time for installation with yarn 2+ - faster is always great 🍾 :

hyperfine  --warmup 1 --prepare 'rm -rf node_modules' --runs 5 'yarn install --immutable'
Benchmark 1: yarn install --immutable
  Time (mean ± σ):     55.868 s ±  0.637 s    [User: 71.734 s, System: 37.474 s]
  Range (min … max):   54.812 s … 56.484 s    5 runs

And I can access to the webpage with no errors.

@tschaffter tschaffter merged commit dbdc75b into Sage-Bionetworks:main Sep 7, 2022
@tschaffter tschaffter deleted the test-yarn3 branch September 7, 2022 21:53
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.

Explore pnpm and yarn v3 Evaluate not removing node_modules after git merge
2 participants