-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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: migrate to Yarn Modern #6028
Conversation
Context: RDIL and I had been talking about this on Discord. We both investigated in Yarn berry in the past week, but ran into some problems due to our monorepo setup. Seems he's more experienced in this, so I let him champion this migration. |
"@docusaurus/utils": "2.0.0-beta.9", | ||
"@docusaurus/utils-common": "2.0.0-beta.9", | ||
"@docusaurus/utils-validation": "2.0.0-beta.9", | ||
"@docusaurus/core": "workspace:*", |
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.
I guess this is only for testing purposes? I have no idea if it works well with NPM or Lerna.
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.
No, this is how things are done in Yarn 3. Putting an actual version would make it fetch from the npm registry. Plus, this way, the release diff is smaller.
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.
We use lerna to automate the release (yes, a weird mix of yarn workspaces and lerna). In the perfect world we ditch lerna altogether in this PR, but otherwise we have to make sure they interop
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.
Putting an actual version would make it fetch from the npm registry
NIT: Only if the range doesn't match the version of the workspace
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.
Wait, @merceyz Does that mean we can keep using the actual version (2.0.0-beta.9
) in the workspace and publish with lerna?
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.
Actually—no, let's not get stuck on the good old lerna forever. @slorber What's your call? Should we migrate to using Yarn workspaces throughout or should we continue using lerna, provided they would have similar DX and no user-side differences?
package.json
Outdated
@@ -38,8 +39,7 @@ | |||
"canary:bumpVersion": "yarn lerna version `yarn --silent canary:version` --exact --no-push --yes", | |||
"canary:publish": "yarn lerna publish from-package --dist-tag canary --yes --no-verify-access", | |||
"changelog": "lerna-changelog", | |||
"postinstall": "run-p postinstall:**", | |||
"postinstall:main": "yarn lock:update && yarn build:packages", | |||
"postinstall": "run-p postinstall:\"**\"", |
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.
are you sure about this?
i think you are missing
"postinstall:main": "yarn build:packages",
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.
I'm still investigating this. It seems the postinstall
hooks aren't even executed
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.
It seems the postinstall hooks aren't even executed
They are, but only when the dependency tree changes.
postinstall is called after a package's dependency tree changes are written to the disk -- e.g. after a dependency or transitive dependency is added, removed, or changed
https://yarnpkg.com/advanced/lifecycle-scripts
package.json
Outdated
"build": "yarn build:packages && yarn build:website", | ||
"build:packages": "lerna run build --no-private", | ||
"build:packages": "yarn workspaces foreach --no-private run build", |
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.
are you sure about this change?
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.
i think you are missing now
"build": "yarn workspaces foreach run build",
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.
This is implied. yarn build
seems to work even without a custom script
Edit. NVM, yarn build
is from the yarn.build plugin
.yarnrc.yml
Outdated
- path: .yarn/plugins/@ojkelly/plugin-build.cjs | ||
spec: "https://yarn.build/latest" |
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 you explain why do we need this plugin?
i don't see any use case for yarn.build -> https://github.com/ojkelly/yarn.build
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.
Yes, RDIL and I had been talking with Owen on Discord and he recommended tophat/monodeploy instead
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.
@armano2 right now I'm using it to actually get the packages to build with an output, plus it has a nice UI.
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.
👋 yeah for sending the packages to npm, tophat/monodeploy is probably a good choice.
yarn.build is more like a bazel/buck, so can build local workspaces in the correct topological order with as much concurrency as possible, and it keeps a record of what's been built so it only rebuild what's changed.
It's also great for doing the same with tests yarn test
and you'll find it most powerful when each workspace is treated as a self contained unit.
If you pair it with yarn's vendoring, then you get the speed and soundness from the big tools like bazel/buck.
@@ -559,14 +559,14 @@ export function getMinimizer( | |||
// Using the array syntax to add 2 minimizers | |||
// see https://github.com/webpack-contrib/css-minimizer-webpack-plugin#array | |||
new CssMinimizerPlugin({ | |||
// @ts-expect-error: the lib def looks terrible... |
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.
what is the reason for code change here?
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.
This I have little idea. The typechecking is now reporting errors in different places
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.
I believe it has to do with typescript getting the type definitions from a different place. Not 100% sure what's going on here either.
To quote the Yarn website: In a few words, upgrading to the latest versions is critical to a fast and stable Yarn experience. Numerous bugs were fixed since the first major version, and we no longer expect to build new features on the old trunk. Even if you don't plan to use the new default installation strategy called Plug'n'Play your projects will still get benefits from the upgrade:
And of course a very active development cycle. LONG VERSIONWhile the Yarn Classic line (1.x) remains a pillar of the JavaScript ecosystem, we recommend upgrading if possible. Why's that?
|
It's now or never. We aren't blocked by anything; Yarn v3 is fully stable. This is also internal so there's no release schedule / pressure from users, but it's better if we start doing something |
Thanks I understand these advantages, but this looks more like an internal quality of life improvement than a critical thing we need asap.
I don't really understand what you mean. What prevents us to do this upgrade after 2.0? If we work on this now, this delays 2.0 due to reviewing this PR, ensuring the release process still work as before, the changelog (using lerna-changelog) can still be generated, the canary releases keep working, and various other things that I may not think of. If it's clear that all the work is done up-frontand well-tested in this PR, including a full release workflow, it's more likely to be merged as it's less likely that this becomes a time sink for me due to unplanned issues TL.DR: the most important for me is a good step by step test plan that I can simply unroll to be 100% sure that everything will work after merge |
Indeed. It's just internal; there's no release schedule. It doesn't block the v2 official release and you shouldn't stress about reviewing it. We're just keeping it here so people know that there's a work in progress. Everything else can move on.
I was saying that "maybe not now" is not adequate because if there's a motivation and nothing's preventing us from doing it, we should do it rightaway, otherwise it would stay in the backlog forever. Anyways, @slorber don't worry too much about this, @RDIL and I will need to make it production ready first before marking it as ready for review. |
@merceyz We are currently using Yarn canary, but the build size report action is still failing when running |
Summary of the workflows we need to check:
|
Sort of, its change from - installScript = npm = `yarn --frozen-lockfile`;
+ npm = `yarn`;
+ installScript = `yarn --frozen-lockfile`;
Add the |
Thanks! Just curious, is there a way to configure this in
That means a fix is still needed for this action. I see. |
Hey all, was wondering on the status of this PR and if it was possible for me to pick up the work on migrating the project to Yarn 4? |
@crutchcorn go for it! I put a pause on working on this because @slorber wasn't sure if it was a good idea to make the switch, but I think a new PR with the conflicts fixed could re-start that discussion. |
I think we could switch to yarn 4 but I'd prefer to keep the node linker for now and turn it on later after testing it a bit more |
@slorber that's totally reasonable. I use the node linker in most of my personal projects, and I think that it tends to generally work better imo. |
Motivation
Switch to yarn v3
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
i'm not done yet
Related PRs
slorber/responsive-loader#1