头图

Each minor version of the Spartacus library contains new features, which are usually improvements to existing components. These features are usually what users expect, but in some cases, these updates may be seen as breaking changes, especially when you build your own customizations on top of specific behaviors or DOM structures.

Feature level

In order to maintain strict backward compatibility, Spartacus includes configurable feature levels, which help improve existing components while maintaining predictable behavior.

By default, the feature level is set to the latest major version (for example, 1.0). To take advantage of the new behaviors and improvements introduced in minor versions (such as 1.3), you can configure the feature level as shown in the following example:

{
  features: {
    level: '1.3'
  }
}

Each successive feature level contains all the features of the previous feature level.

If you want your feature level to always be set to the latest version, you can use the latest flag ('*') as shown below:

features: {
  level: '*'
}

You can also disable features of a specific feature level by adding an exclamation point (!) before the version number. Below is an example:

<newComponent *cxFeatureLevel="'!1.1'"></newComponent>

Feature Flags

Some important functions can be selectively switched using specific function flags.

Below is an example:

{
  features: {
    someFeature: false
  }
}

The function flag can be linked to the function level, and if the defined function level is available, the function is enabled by default.

You can configure the function level and function flag at the same time, as shown in the following example:

{
  features: {
    level: '1.1',
    feature1: false,
    feature2: true
  }
}

In this example, the function level is set to 1.1. Set feature1 to false. If feature1 is usually part of the 1.1 feature set, you can selectively disable this feature while retaining the rest of the 1.1 features.

If feature2 is part of version 1.5, you can enable it by setting it to true, otherwise you can only enable version 1.1 features.

If you selectively enable features, it is recommended that you pay special attention to testing your application. Although feature flags are used for many different Spartacus features, there is no guarantee that all features will apply to all possible combinations of feature flags and feature levels.


注销
1k 声望1.6k 粉丝

invalid