There is currently no standard approach for rolling out breaking changes in GitLab UI components to projects that consume them. Various approaches have been tried in the past, and some have worked better than others. Whatever the approach is, it can get tricky when a component is used in many places in a large codebase, like GitLab.
Here is an outline of an approach that has worked reasonably well. Suppose the
component to receive the breaking changes is called GlFoo
:
-
Introduce a minor version change to GitLab UI that simply re-exports the given component, say
GlFoo
, under an additional name,GlDeprecatedFoo
. The sameGlFoo
export is still available.For example, in
index.js
:- export { default as GlFoo } from './src/components/base/foo/foo.vue'; + export { default as GlFoo, default as GlDeprecatedFoo } from './src/components/base/foo/foo.vue';
-
Open integration MRs with projects that consume GitLab UI (e.g., GitLab) that bump
@gitlab/ui
to the new minor version, and change all existing imports ofGlFoo
toGlDeprecatedFoo
, but alias it back toGlFoo
.For example:
- import { GlFoo } from '@gitlab/ui'; + import { GlDeprecatedFoo as GlFoo } from '@gitlab/ui';
This keeps the diff small and easy to review, since templates don't need to change, and no visual or behavioral changes need to be verified. It also reduces the amount of work that needs to be done in later steps.
-
Duplicate the existing
GlFoo
implementation, naming one copyGlDeprecatedFoo
, and export it asGlDeprecatedFoo
. This copy should receive no further changes. -
Implement the breaking changes on the copy exported as
GlFoo
, and release this in a new major version. -
Open integration MRs with projects that consume GitLab UI (e.g., GitLab) that bump
@gitlab/ui
to the new major version, and fix any additional new uses ofGlFoo
to importGlDeprecatedFoo
instead. The amount of these should be significantly reduced thanks to step 2. -
Open an epic to iteratively upgrade each use of
GlDeprecatedFoo
to the newGlFoo
. There is a script that helps automate some of this. -
Once all uses have been upgraded in the consuming projects, completely remove
GlDeprecatedFoo
from GitLab UI and release it as another major version, since it's another breaking change. -
A final set of integration MRs can now be opened which bump
@gitlab/ui
to the new major version, and any new uses ofGlDeprecatedFoo
(but hopefully there are none) can be upgraded toGlFoo
.
Note that if GlFoo
were only used once or twice in consuming projects, some
of the steps in this process would be unnecessary overhead; it might be easier
to immediately upgrade those uses to the new implementation in the same
integration MR that bumps @gitlab/ui
to the new major version.
Remember to follow our commit conventions to ensure the major version number of GitLab UI is incremented with any breaking changes.