Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Exploration: Managing backwards compatibility across Gutenberg Versions #1014

@nerrad

Description

@nerrad

Context: p90Yrv-1gv-p2

Summary

As the blocks team starts looking to the future and building blocks that do newer and more interesting things in the new realm of WordPress development, it increasingly becomes apparent that it's tough to keep up with the rapid iteration happening in Gutenberg development. While currently WooCommerce blocks require version 5.0 of WordPress and (including the pending WP 5.3 release) that's only 3 versions of back-compat support. It's actually equivalent to supporting 19 versions of Gutenberg releases in that same period of time (Gutenberg 4.7 went into WordPress 5.0 and Gutenberg 6.6 is landing in WP 5.3).

The pace of development has been incredible in the Gutenberg project and has brought many awesome improvements in the underlying packages shipped with WordPress, new blocks, a11y improvements, and performance games. Many of these changes impact not only what we can build for WooCommerce blocks, but also how we build them. As a result, this also impacts backwards compatibility.

A tension we face with WC-Blocks development, is that maintaining backward compatibility for primarily server side apis, is much different than maintaining backwards compatibility for client side apis. Client side involves enqueuing scripts and style bundles that can change significantly between versions and while the GB team has done an admirable job in preserving apis and behaviours along all the versions that are released, the reality is that if we want to provide the latest improvements to end users of our blocks, it's much more difficult to progressively enhance relatively consistent behaviour across multiple WordPress versions.

Next steps

Due to the dilemma introduced above, I'm doing some exploration around a possible solution for WooCommerce blocks. This solution involves:

  • Preserving existing blocks behaviour across the minimum WP version blocks currently support (WordPress 5.0) and only bump that minimum requirement for existing blocks when WC core bumps it's minimum WP core requirements.
  • New blocks requiring the latest Gutenberg behaviour (as determined on a case-by-case basis) will have minimum WordPress version requirements. That means to use that block, your WordPress environment would need to match the minimum requirements for that version.

Practical considerations:

  • We want to isolate any conditional loading/initialization so that when WC core bumps it's minimum WP version requirements, we can remove any legacy code retained for back-compat reasons.
  • We need to monitor the dependency chain of components to ensure existing blocks don't use consume a component that requires a higher version of WordPress.
  • The above may necessitate doing "legacy" builds for older versions of WordPress supported so that we can load those bundles in those environments instead of the new bundles.
  • To keep code churn to a minimum (and isolate branches), only have separate forks/branches of a component when needed and simply consume the correct component for an environment in a built bundle (which can be done via webpack aliasing for imports).
  • We'll want to limit what branches we maintain to at most two (let's see if we can do that). This means if we introduce a block using components that requires WP 5.3, then any legacy build (if necessary) would be loaded for WP5.0-WP 5.2 and the main build will be loaded for WP 5.3+. We would not introduce a block with new WP version requirements greater than 5.3 until Woo Core bumps it's minimum version requirement for WP to 5.3 (thus we can eliminate the legacy build).
  • In cases where we have existing blocks utilize legacy components in a legacy build but consume newer components in the main build, we'll have to ensure that primary block behaviour is the same so there are no invalidation issues and the transition for the merchant is painless (ideally, they don't even notice it) when they update their WordPress version on their site.

Exploration items

The following is a list of specific things to explore as a part of the solution and with the practical considerations in mind. It is not exhaustive and will likely be updated as I work on things.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions