Design principle of feature module of Spartacus UI of SAP e-commerce cloud

Time:2021-12-30

We illustrate the principle with a specific example.

Let’s check the public in an integration Library Directory_ api. ts:

Design principle of feature module of Spartacus UI of SAP e-commerce cloud

Focus on module:
Design principle of feature module of Spartacus UI of SAP e-commerce cloud

The module contained in this lib is epdvisualizationmodule and the corresponding configuration: epdvisualizationconfig

Design principle of feature module of Spartacus UI of SAP e-commerce cloud

Note that the eighth line imports the visualpickingtabmodule, which is the module containing the angular component

The entry is visualpickingtabcomponent:
Design principle of feature module of Spartacus UI of SAP e-commerce cloud

For Spartacus, it only cares about the top-level EPD visualization module

SpartacusFeaturesModule

Design principle of feature module of Spartacus UI of SAP e-commerce cloud

Spartacus features module is designed to easily manage all non core Spartacus functions, including static loading and deferred loading. It serves as the entry point for all functions, which are ideally packaged into their own independent functional modules.

In the early 3 In the X minor version, Spartacus features module may look bloated and busy, but with each successive release, it should become more concise because of efforts to move most of the functionality to a separate library.

Ideally, a complete function can be encapsulated into a specific function module. This module can contain configuration and customization related to functions.

Design principle of feature module of Spartacus UI of SAP e-commerce cloud

Determine which feature modules to insert into the array featuremodules according to the value corresponding to the environment variable environment.

last

Design principle of feature module of Spartacus UI of SAP e-commerce cloud

The module imported by spartacusfeaturemodule contains two parts: the core module (hard coded) of the mandatory and the module in the featuremodules array described above.

Design principle of feature module of Spartacus UI of SAP e-commerce cloud

Linux system:

export SPA_ENV=epd-visualization
Design principle of feature module of Spartacus UI of SAP e-commerce cloud

Windows system:
set CX_EPD_VISUALIZATION=true&& yarn start:local

Turn on CX_ EPD_ After visualization, you can see the corresponding CMS mapping:

Design principle of feature module of Spartacus UI of SAP e-commerce cloud

More Jerry’s original articles are: “Wang Zixi”:
Design principle of feature module of Spartacus UI of SAP e-commerce cloud