-
Notifications
You must be signed in to change notification settings - Fork 30
👋 yarn@1
: align some DCR deps
#9565
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
Conversation
Size Change: 0 B Total Size: 700 kB ℹ️ View Unchanged
|
049da2f
to
5fb9102
Compare
5fb9102
to
94761fa
Compare
@@ -41,8 +41,7 @@ | |||
"lint-staged": "13.2.1", | |||
"npm-run-all": "^4.1.5", | |||
"prettier": "3.0.3", | |||
"tslib": "2.5.3", | |||
"typescript": "5.1.3" |
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.
Does TypeScript need to be removed from the top-level package? Does this not increase the risk of mismatched TS versions? And why would tslib
be left there?
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.
Does TypeScript need to be removed from the top-level package? Does this not increase the risk of mismatched TS versions?
So nothing in the root actually uses TypeScript.
Right now, this root dependency is only there to provide DCR with TypeScript (because DCR doesn't declare a dependency on it), but not AR (which has a declared dependency an earlier version and is not part of the workspace).
As you suggest, there are two ways of providing common deps like this - installing them once in the root, or by requiring projects in the workspace to be explicit.
In csnx, we've found it a lot more straightforward to have projects declare their own dependencies (the ones declared here are for deps that are also used by the root, so we know are present – this set up also feels a bit weird to me).
But if you chose to provide them all from the root, then you need to know exactly which dependencies all projects have, manually decide which of those make sense to pull up to the root, and then keep on top of whether those projects continue to need them (since they're not declared anywhere, how do you know?).
You are also bound to change all projects simultaneously, which can make a simple bump in one package a far more complicated change as you fix a load of issues in unrelated packages.
The trade off is needing to manually keep common dependencies in sync (note these are not peerDeps, just common deps – as long as packages declare peerDependencies
, this should be safe).
Moving common dependency declarations to the root does guarantee version parity across projects, but at the cost of flexibility and an increased maintenance overhead (are the assumptions in the root still correct?).
It's also worth considering that AR and DCR currently use different versions of TypeScript without issue. In CSNX we have linting scripts, for example, in the root that run across all projects that we therefore want to only use the root version of eslint
.
I think it's tempting to think that version parity is always preferable over drift, but the cost of forcing it is high and where it's not a direct a benefit (i.e. the code can run) it's not proven to be worth it, at least in our experience of CSNX.
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.
And why would
tslib
be left there?
it's a peer dep of @guardian/prettier
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.
Thanks for a very clearly explained rationale in https://github.com/guardian/dotcom-rendering/pull/9565/files#r1400398584
I’d suggest bringing this up in the PR description, as it’s one of the best writeup on the distinction between root and workspace dependencies I’ve seen! 👏
What does this change?
aligns some root and dcr deps, making the workspace more explicit and apps less dependent on yarn 1's hoisting
edit: a wider discussion about this took place in the comments, including a breakdown of the rationale (which should have been in the description originally really) – see #9565 (review) for more info
Why?
prep for moving away from yarn 1