| 1 | # 4. Code sharing between Vector and Minerva Skins |
| 2 | |
| 3 | Date: 2024-03-07 |
| 4 | Updated: 2024-03-19 |
| 5 | |
| 6 | ## Status |
| 7 | |
| 8 | Accepted. |
| 9 | |
| 10 | ## Context |
| 11 | |
| 12 | Exploring effective strategies for code sharing between Vector and Minerva Skins to reduce duplication and improve maintenance. Key options considered include creating a Composer library for shared functionalities, duplicating code in both skins, and moving shared code to the MediaWiki core. |
| 13 | |
| 14 | On the short term this relates to solving the problem at T359606 and on the long term this might apply to things like the feature management system. |
| 15 | |
| 16 | ## Decision |
| 17 | |
| 18 | After thorough consideration, the following options are under evaluation for code sharing between Vector and Minerva Skins: |
| 19 | - **Creating a Composer Library**: Centralizing shared functionalities to reduce duplication and improve update management. |
| 20 | - **Duplicating Code**: Implementing similar functionalities independently in both skins, prioritizing flexibility and skin-specific optimizations. |
| 21 | - **Moving Shared Code to MediaWiki Core**: Leveraging the core platform to provide shared functionalities, enhancing accessibility and consistency across skins. |
| 22 | |
| 23 | After some more discussion some other options emerged: |
| 24 | - **A git submodule** that is initialized inside Minerva and Vector. |
| 25 | - **A shell script** that copies the files from Vector to Minerva. |
| 26 | - **Making Minerva depend on Vector** add a soft dependency on Vector from Minerva. |
| 27 | |
| 28 | We assessed each option on development efficiency, maintenance, and the ability to support future enhancements. After discussion there was agreement among the team about the following: |
| 29 | - Composer libraries should not depend on MediaWiki in any way. |
| 30 | - Ideally shared skin code should live in MediaWiki core |
| 31 | - Code in core should not be specific to Minerva and Vector and should be generally useful and should not be rushed. |
| 32 | |
| 33 | We recognized the fact that often the web team needs to balance shipping products and agreed on the following: |
| 34 | **On the short term we would make Minerva depend on Vector** |
| 35 | |
| 36 | Reasoning: |
| 37 | - This minimizes disruption to third parties. If we were to use a submodule, this would alter how people upgrade/install Vector. |
| 38 | - We think that there are few installs where Minerva is installed but Vector isn't. In Minerva we can use a soft dependency to avoid breaking changes. |
| 39 | - It would avoid issues relating to ensure Minerva and Vector's submodules are in sync and using the same version. For example, it would be possible |
| 40 | with the submodule approach that Vector and Minerva use different versions of the shared skin. |
| 41 | - Minerva would automatically benefit from updates to Vevtor. |
| 42 | - Since Minerva and Vector are in the CI pipeline, our integration tests should protect against making breaking changes. |
| 43 | |
| 44 | ## Consequences |
| 45 | |
| 46 | The shared repository is intended as a way to manage code shared between Vector and Minerva more efficiently. However the expectation is that when |
| 47 | code is shared it should eventually be upstreamed to core and a Phabricator ticket should document that. |
| 48 | For example, T360452 has been created for the long term solution for our immediate need. |
| 49 | |
| 50 | The sharing of code, means we must consider the Vector code a stable interface for Minerva to use. |
| 51 |