-
Notifications
You must be signed in to change notification settings - Fork 995
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
Upgrade Framework to Yarn v3 #3154
Conversation
re: Cypress --> missing dependencies, e.g. |
The main problems you are facing with Yarn 3 is that Yarn is now strict about binaries you run from your workspaces. You are not allowed to run If its okay to add these dependencies you can do this via: |
I believe build, lint, and test are all working correctly. I do have a build:clean warning to diagnose:
Cypress E2EThe
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems some install-state.gz
files got committed by accident, they should be gitignored as well
🚀 This is ready to merge. To Do:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we jump on a call to discuss this PR. It appears to break my mental model of "framework-tools" and I just want to discuss what the constraints and workarounds are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy for this to go in after our discussion.
Continued in #3516 |
related to #2907
cc @larixer
Overview
This PR is now ready for review.
Yarn v3 is a significant improvement over v1. Performance is snappier and resolutions are greatly improved. The new features like
doctor
have identified previously unknown issues.Additionally, this resolves the "connection time out" error we were seeing in CI checks, which means overall CI time is about 30-50% reduced (depending on cache-hit status).
We can proceed with using Yarn v3 for the Framework and Yarn v1 for Projects. Once we are comfortable with Yarn v3 (and have tested upgrading Projects via canary releases), we can suggest projects migrate to v3. Assuming the migration is smooth, I see us moving the CRWA template to Yarn v3 sooner than later because of the performance and stability gains.
Reference:
Current Status
This upgrade was significantly more feasible than my previous attempt to upgrade to Yarn v2. 🚀 Overall, I'm excited about the bug-fixes and potential performance improvements (including CI E2E). This is looking solid.
Note: using v3 on the Framework does not require upgrading Redwood Projects to use v3. (However, we might determine this is a simple + helpful recommendation in the future.) Also, the v3 binary is installed in the project directory itself, which means you can have v1 installed globally and only use v3 when in the context of the Framework project. Slick...
New Yarn utilities
yarn add --interactive
Reuse the specified package from other workspaces in the project. Example:
yarn workspaces foreach ...
This is a command from the workspaces plugin. Runs the command across all workspaces. Example:
-v: outputs the package name the command is currently running against
Added to CI: dedupe and constraints
yarn dedupe --check
yarn constraints
See new file
constraints.pro
for repo configToDo
yarn lint
eslint erroryarn install
does not run the scriptpostinstall
. However, I can runyarn postinstall
successfullygit clean -fxd
. Apparently it doesn't run unless changes/updates have occured.yarn rwfw project:sync
with a local Redwood project against this branch (Framework using yarn v3)yarn lint
(cross-platform compatibility when passing Env)Notes
"Binary hoisting" is no longer allowed
Example:
This is a significant change for us — for example, to run build and test within individual packages, we had to install babel, typescript, and jest within each workspace package.json.
Specifying Yarn v1 binary (when necessary)
Yarn v1 is installed globally and Yarn v3 is specified locally, which allows us to use both at the same time. However, in the case a script is called via
yarn run [script]
(e.g.yarn build:test-project
), the process defaults to using the Yarn v3 binary for all yarn commands. This will break the yarn commands run within the new test-project directory, for example. So we ended up learning a lot of tricks to manage which yarn binary is used.Use
yarn dlx
Example: run yarn v1 install
We also ended up needing to set the packageLocator, which is null in Yarn v3 and the value would be passed down to Yarn v1 executed command. Note: would need to use cross-env or otherwise for multi-platform compatibility.
Example:
Set
YARN_IGNORE_PATH=1
This ignores the local yarn version settings. Note: would need to use cross-env or otherwise for multi-platform compatibility.
Example:
** Set version in directory**
This adds a .yarnrc file that explicitly sets v1. Note: this is what we ended up using here.
Example:
postinstall
The postinstall script (in package.json) was not always executing. I found this explanation, which explained what I was experiencing: