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.
定制化和第三方代碼進一步增加了項目復雜度,如果處理不得當,很容易出現堆砌了大量 module,難于維護的情況。
This can be solved by defining and adhering to a standardized structure, such as the Spartacus reference app structure.
而遵循 Spartacus reference app structure 來開發,就能避免此類問題出現。
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.
有一套標準的工程結構,也便于新開發人員進入項目后,快速熟悉項目并上手。
結構
1. AppModule
2. SpartacusModule
3.BaseStorefrontModule
從 @spartacus/storefront 里導入,再導出。
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 應用都有一個 root app module,通常命名為 AppModule. 在 SAP Spartacus reference app structure 里,AppModule 包含了應用層級的 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,因為整個應用的其他定制開發很可能也會用到,因此直接在 AppModule 里 import,而沒有放到 SpartacusModule 里。
SpartacusModule 包含三部分:
包含了任何 Spartacus 應用都必需的 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 相關的配置信息,推薦放到 feature modules 里,從而遵循關注點分離的原則。
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的SAP Spartacus Reference App Structure的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab练习程序(克莱姆法则解方程)
- 下一篇: RxJs fromEvent 工作原理分