当前位置:网站首页>SAP Spartacus Reference App Structure

SAP Spartacus Reference App Structure

2022-06-11 10:50:00 Hua Weiyun

https://sap.github.io/spartacus-docs/reference-app-structure/

The concept is in SAP Spartacus 3.1 Version to introduce .

This Reference App Structure yes SAP Recommend that customers build their own Spartacus Storefront Reference used when .

Spartacus Contains a number of that can lazy load Of feature libraries.

Customizations and third-party code add further complexity, and you can end up with modules that are difficult to maintain because they mix too many of these elements together.

Customization and third-party code further increase the complexity of the project , If not handled properly , It's easy to pile up a lot of module, Difficult to maintain .

This can be solved by defining and adhering to a standardized structure, such as the Spartacus reference app structure.

And follow Spartacus reference app structure To develop , Can avoid such problems .

Having a standardized structure also makes it easier to onboard new developers to your project, to handle external support cases, and to take care of audits.

There is a set of standard engineering structures , It is also convenient for new developers to enter the project , Quickly familiarize yourself with the project and get started .

structure

1. AppModule

2. SpartacusModule

3.BaseStorefrontModule

from @spartacus/storefront Import in , Then export .

4.SpartacusFeatureModule

5. feature related modules

6. To configure module

Every Angular application has a root app module, usually named AppModule. In the reference app strcuture, this module includes application-wide imports, and avoids complex module imports related to Spartacus by handling only one SpartacusModule.

Every Angular Every app has one root app module, Usually named AppModule. stay SAP Spartacus reference app structure in ,AppModule Contains application level imports:

Both Angular Router and NgRx are used by Spartacus, but these affect the global application, so they are kept outside of the SpartacusModule and are imported directly in the AppModule.

As can be seen from the above figure ,StoreModule and EffectsModule etc. module, Because other customized development of the entire application may also be used , So directly in AppModule in import, Instead of putting SpartacusModule in .

SpartacusModule It consists of three parts :

  1. The BaseStorefrontModule, which encapsulates core Spartacus imports that are usually required by most Spartacus applications.

Contains any Spartacus Applications are required imports.

The BaseStorefrontModule is imported directly from @spartacus/storefront.

  1. The SpartacusFeaturesModule, which encapsulates Spartacus features.

Spartacus feature It's divided into two parts : come from @Spartacus/storefront and features Under folder modules.

  1. The SpartacusConfigurationModule, which encapsulates the general Spartacus configuration.

Configuration information :

Feature-specific configurations can be kept either in feature modules, or in the SpartacusConfigurationModule. Keeping them in feature modules helps to maintain a good separation of concerns, so it is generally recommended.

feature Related configuration information , It's recommended to put feature modules in , So as to follow the principle of separation of concerns .

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111034478856.html