SAP Spartacus Reference App Structure
https://sap.github.io/spartacus-docs/reference-app-structure/
該概念在 SAP Spartacus 3.1 版本引入。
這個 Reference App Structure 是 SAP 推薦客戶在搭建自己的 Spartacus Storefront 時所用的參考。
Spartacus 包含若干可以 lazy load 的 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.
定制化和第三方代碼進一步增加了項目復(fù)雜度,如果處理不得當(dāng),很容易出現(xiàn)堆砌了大量 module,難于維護的情況。
This can be solved by defining and adhering to a standardized structure, such as the Spartacus reference app structure.
而遵循 Spartacus reference app structure 來開發(fā),就能避免此類問題出現(xiàn)。
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.
有一套標(biāo)準(zhǔn)的工程結(jié)構(gòu),也便于新開發(fā)人員進入項目后,快速熟悉項目并上手。
結(jié)構(gòu)
1. AppModule
2. SpartacusModule
3.BaseStorefrontModule
從 @spartacus/storefront 里導(dǎo)入,再導(dǎo)出。
4.SpartacusFeatureModule
5. feature related modules
6. 配置 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.
每個 Angular 應(yīng)用都有一個 root app module,通常命名為 AppModule. 在 SAP Spartacus reference app structure 里,AppModule 包含了應(yīng)用層級的 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.
從上圖可見,StoreModule 和 EffectsModule 等 module,因為整個應(yīng)用的其他定制開發(fā)很可能也會用到,因此直接在 AppModule 里 import,而沒有放到 SpartacusModule 里。
SpartacusModule 包含三部分:
包含了任何 Spartacus 應(yīng)用都必需的 imports.
The BaseStorefrontModule is imported directly from @spartacus/storefront.
Spartacus feature 又分為兩部分:來自 @Spartacus/storefront 和 features 文件夾下的 modules.
配置信息:
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 相關(guān)的配置信息,推薦放到 feature modules 里,從而遵循關(guān)注點分離的原則。
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結(jié)
以上是生活随笔為你收集整理的SAP Spartacus Reference App Structure的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab练习程序(克莱姆法则解方程)
- 下一篇: RxJs fromEvent 工作原理分