-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Case Study] Experience using on a medium sized codebase #843
Comments
I was having similar problems just trying yarn2 with a freshly initiated nextjs app. My only solution: Go back to using good ol' node_modules by adding Using yarn2 is definitely not a smooth transition at the moment. Hoping it can get there soon! |
Will try the node_modules linker when I get some more time to work on this. |
Agreed, yarn berry is a nightmare to migrate at present. The documentation states its compatible with most tooling such as babel etc... Although when one actually attempts a migration it's clear that this is far from the case. |
Regarding Test2 (Duplicate workspace name): This error message appeared for me because I had a monorepo and was upgrading it in-place to Yarn2. Check your repo for existing node_module directories and delete them all, not just the root directory, before running yarn. I've submitted a PR to improve the error message with explicit locations of the dup'ed, which will hopefully make this clearer in future. |
Thanks for the report, I've gone over this issue a few times since you opened it so it hasn't been ignored. We've improved a lot of things since this was opened by fixing bugs both in Yarn and upstream so the experience should be a lot smoother now. The documentation has been updated as well and should make the migration easier. If you'd like to give this another go so we can see what still needs improving that would be nice.
It's hard to say what happened here and without a reproduction not much we can do.
You most likely had a workspaces pattern that included
It's possible to set the version without running an install now so this is fixed (#1261).
Seems to be using native files which we now unplug automatically, however if they're trying to read from the zip files then it wont work so you'll either need to unplug whatever they're trying to read or use node_modules.
We've improved the errors so they show all the info needed now (who, what, and where).
We've fixed the PnP issues in Next.js and both they and us have e2e tests that cover this now so that should prevent issues from happening in the future. |
What package is covered by this investigations?
No specific package were investigated. I'm mostly looking at the overall user experience of migrating to berry. We can go into more detail of specific issues later.
Describe the goal of the investigation
Investigate the usability of berry in the current state of the javascript ecosystem in a medium sized yarn workspace codebase. The codebase is ~3 years old with very little legacy code. All packages were updated about a week ago.
It contains the following apps which I expect berry to work:
It also contains 2 react-native apps that I removed for the purpose of this test as it is not supported. It contains a nodejs / aws lambda backend that I will leave in the test as I'm not sure if it will be compatible or not.
Here's the result of running cloc on the codebase:
Result of
yarn list --depth=0
is around 3000 packages.https://gist.github.com/janicduplessis/e676e01503e12028f1718b6c68683f82
Investigation report
Note that I did not go through the Migration guide on purpose before doing these tests to simulate what the average user would do. I'm only reading the getting started section on the website.
Test 1
Deleted all yarn related files and
node_modules
to test like the project never used yarn before.No idea what is going on here.
Test 2
Reinstall everything using yarn v1 and try to upgrade instead.
Again not sure what is going in here. Let's try to delete node_modules.
I guess
yarn policies set-version berry
is for per project install and should not be needed. Let's just try yarn install.Looks like api code won't be compatible since it uses bucklescript and it doesn't seem compatible currently. Also the
serverless-webpack
package has an integration with yarn / npm for external modules and will surely not work since I know it relies on the node_modules directory.I have no idea what the other error is.
Modules seem to have installed fine anyway and errors come from postinstall scripts so let's try to run the CRA project.
The error seem to come from a transitive dependency, but I have no idea how to edit my dependencies so I can't hack around it. Will do some research on the error and come back to it later. Let's try to run the gatsby project.
Similar error, again in transitive dependencies. NextJS next.
This one is actually coming from my code, let's add
"@babel/core": "^7.8.3",
to the project's package.json and yarn install again.I'm not using
@babel/preset-flow
but lets try to add it to my package.json see if it helps.Back with an error from a dependency. At this point I'm going to go read the migration guide see if I can find something there. Let's also try to run the doctor tool see if it can give some useful information.
Result is here https://gist.github.com/janicduplessis/d71525ec8eb0692415465c73f5b4157c. TBH there is so much stuff that I'm not sure where to start. Almost everything is
Unmet transitive peer dependency
.Let's go back to the first error in the CRA app. There is a section about it in the getting started guide https://yarnpkg.com/advanced/migration#a-package-is-trying-to-access-another-package-.
The error was
The error only mentions victory-brush-container so I will look there, however I'm not sure what is the "first" and the "second" dependency the error message talks about. To figure out what was going on I went and looked at the source for victory-brush-container and found it was missing a dependency on react-fast-compare https://github.com/FormidableLabs/victory/blob/master/packages/victory-brush-container/src/brush-helpers.js#L3.
According to the migration guide I can use https://yarnpkg.com/configuration/yarnrc#packageExtensions to fix those.
Let's add a yarnrc file with
It did fix this error but a similar one in another victory package came up. I checked the result of yarn doctor and it doesn't say anything about victory packages. At this point I would have to keep fixing one error, running yarn install and repeat until no errors are left. For now I will just remove victory from the codebase to get to the next step.
Same error again but with a different package
react-native-safe-area-context
(this is my library lol). In this case it was missing a peer dep on react. Adding it to yarnrc.This time for some reason it doesn't work. This file mentionned in the error is https://github.com/th3rdwave/react-native-safe-area-context/blob/master/src/NativeSafeAreaView.web.tsx#L1-L2 and only includes imports to react and react-native. The library has peer deps on react native but is missing react https://github.com/th3rdwave/react-native-safe-area-context/blob/master/package.json#L41.
Adding the following entry in packageExtensions doesn't fix the error after running yarn install and starting the project again.
At this point I'm kind of stuck. Could go down another rabbit hole in another project but I'm done for tonight. I might try to fix the missing peer dep in my library to see if it fixes the error.
The text was updated successfully, but these errors were encountered: