@shopgate/webpack 7.31.1-alpha.1 → 7.31.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/getComponentsSettings.js +33 -1
- package/package.json +1 -1
|
@@ -22,6 +22,38 @@ const importFresh = require('import-fresh');
|
|
|
22
22
|
* system
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
const ignoredExtensions = [
|
|
26
|
+
'@shopgate/product-reviews',
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Removes ignored extension entries from one config section.
|
|
31
|
+
* @param {Object} section The component settings section.
|
|
32
|
+
* @returns {Object}
|
|
33
|
+
*/
|
|
34
|
+
const filterIgnoredEntries = (section = {}) => Object.keys(section).reduce((acc, key) => {
|
|
35
|
+
const isIgnored = ignoredExtensions.some(ignored => key.startsWith(`${ignored}/`));
|
|
36
|
+
|
|
37
|
+
if (isIgnored) {
|
|
38
|
+
return acc;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...acc,
|
|
43
|
+
[key]: section[key],
|
|
44
|
+
};
|
|
45
|
+
}, {});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Removes ignored extension entries from component config sections that come from the sdk.
|
|
49
|
+
* @param {ComponentSettings} config The raw component settings.
|
|
50
|
+
* @returns {ComponentSettings}
|
|
51
|
+
*/
|
|
52
|
+
const filterIgnoredExtensions = (config = {}) => Object.keys(config).reduce((acc, sectionName) => ({
|
|
53
|
+
...acc,
|
|
54
|
+
[sectionName]: filterIgnoredEntries(config[sectionName]),
|
|
55
|
+
}), {});
|
|
56
|
+
|
|
25
57
|
/**
|
|
26
58
|
* Returns contents of the `config/components.json` file from the theme.
|
|
27
59
|
*
|
|
@@ -44,7 +76,7 @@ module.exports = function getComponentsSettings(themePath) {
|
|
|
44
76
|
const themeWidgetsV2Config = '@shopgate/engage/page/widgets/widgets.json';
|
|
45
77
|
|
|
46
78
|
/** @type {ComponentSettings} */
|
|
47
|
-
const defaultConfig = importFresh(`${themePath}/config/components.json`);
|
|
79
|
+
const defaultConfig = filterIgnoredExtensions(importFresh(`${themePath}/config/components.json`));
|
|
48
80
|
|
|
49
81
|
/**
|
|
50
82
|
* Loads a JSON config file using `import-fresh`, if it exists.
|