Skip to content

Deprecating component properties

Rémy Denton edited this page Jul 8, 2021 · 6 revisions

I. For Bolt PRs that introduce a deprecation

  1. Update code so that both the new and deprecated properties work (backward compatibility). For example, if you deprecating an itemAlignment property in favor of align, the twig might look like this:

    {% if itemAlignment %}
      {% if itemAlignment == "start" %}
        {% set itemAlignment = "left" %}
      {% endif %}
      {% set align = itemAlignment %}
    {% endif %}
  2. Update the component's schema.

    • Document the deprecated property. For example:

      {
        title: 'Bolt Button',
        itemAlignment: {
          title: 'DEPRECATED',
          description: 'Use the align parameter instead.',
        },
      }
    • Mark the schema as invalid if the deprecated property is present. For example:

      {
        title: 'Bolt Button',
        not: {
          required: ['itemAlignment']
        },
      }

      Note that if multiple props are deprecated in a single component, you'll need to use this unintuitive syntax:

      {
        title: 'Bolt Button',
        not: {
          anyOf: [
            {
              required: ['itemAlignment'],
            },
            {
              required: ['rounded'],
            },
          ],
        },
      }
  3. Update all usages in PL to remove usages of deprecation. Because of your schema updates, the build should not work until you've found them all.

  4. In the PR description, describe the deprecation and steps to update legacy code

II. For a minor release that includes a deprecation (e.g. 1.7, 1.8)

  • When merging, copy the deprecation description from the PR to the Deprecations section of the release notes.
  • As for all releases, point developers doing the integration to the release notes. Encourage them to update their existing code immediately to remove the deprecation when integrating the new version of Bolt.

III. For a major release that is not backwards compatible (e.g. 2.0, 3.0)

  • Use the schema to check for usages of the not required syntax to go back through and remove deprecations. Remove them from the schema too-- they will now simply just not work.
  • As you do this, generate a list of previously deprecated features that are now officially removed (this should ultimately match the cumulative result of all 'Deprecated' release notes from the past release).

Note: the workflow is still loose on the Drupal side because we've done so few major releases, but the current plan is that properties won't really worry much about deprecations until it comes time for a major release, and which point they'll go through a list of removed features and make updates on their end.

Clone this wiki locally