chore(components): use npm overrides to force transitive leafygreen dependencies to the same version of shared packages #7223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are currently in a pretty nasty state where we can't easily add new leafygreen dependencies because our local versions are not up to date. Adding new deps in most cases forces us to update other leafygreen dependencies, which causes issues across the whole codebase that are not easy to fix.
This is especially a pain point right now for multiple projects that depend on new leafygreen components that we don't have any way of easily rebuilding ourselves. We already had to vendor in the Drawer component, and the leafygreen chat is even more of an issue because it's basically a whole monorepo of its own that we will have to include.
Lucky for us though, it seems like while there are multiple major version updates in leafygreen, not all of them are meaningfully breaking for components we are trying to add dependencies on, at least at a glance (this is something that @gagik managed to prove by doing an initial pass of vendoring
@lg-chat
into compass in this POC) and so one option that we seem to have instead of vendoring 16 different packages that@lg-chat
consists of, is using npm overrides feature to just force all shared leafygreen dependencies to the same version, this is what this patch is doing.To be super clear, this is a massive hack: npm is fiddly and sometimes ignores overrides altogether or overrides them back to original values outside of your control on unrelated installs, sometimes behavior is even slightly different between minor npm versions, overrides don't apply to peer dependencies so we still have to force npm install when adding new deps, and we also have no guarantees that this doesn't actually break any of the leafygreen components. At a glance nothing broke, but any next update might not go through at all. Hopefully our tests are good enough to catch this.
At the same time this is still somewhat cleaner than pulling half of leafygreen monorepo as-is in our code. This is hopefully a short lived solution that we will not need to keep in the repo for long and can remove as soon as leafygreen update is finished, but this should allow us to move forward for now in the cleanest way possible.
First commit only makes sure that all existings dependencies are aligned and adds explicit dependencies to two new leafygreen packages that we are currently missing that lg-chat depends on. In the second commit I'll add all lg-chat dependencies and re-export through compass-components. Wanted to open PR already to have some initial CI runs going