@riosst100/pwa-marketplace 1.1.3 → 1.1.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/intercept.js +38 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "1.1.3",
4
+ "version": "1.1.5",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
package/src/intercept.js CHANGED
@@ -2,6 +2,7 @@ const componentOverrideMapping = require('./componentOverrideMapping');
2
2
  const moduleOverridePlugin = require('./moduleOverrideWebpackPlugin');
3
3
  const { DefinePlugin } = require('webpack');
4
4
  const { getAvailableWebsitesConfigData } = require('./Utilities/graphQL');
5
+ const LocalizationPlugin = require('@magento/pwa-buildpack/lib/WebpackTools/plugins/LocalizationPlugin');
5
6
 
6
7
  module.exports = targets => {
7
8
  // Perform the asynchronous operation outside the tap
@@ -20,6 +21,43 @@ module.exports = targets => {
20
21
  new moduleOverridePlugin(componentOverrideMapping).apply(compiler);
21
22
  });
22
23
 
24
+ // Tap into webpackCompiler
25
+ targets.of('@magento/pwa-buildpack').webpackCompiler.tap(compiler => {
26
+ // Check if the LocalizationPlugin is present
27
+ if (compiler.options.plugins) {
28
+ const localizationPlugin = compiler.options.plugins.find(
29
+ plugin => plugin instanceof LocalizationPlugin
30
+ );
31
+
32
+ // Check if LocalizationPlugin is found
33
+ if (localizationPlugin) {
34
+ // Store the original mergeLocales function
35
+ const originalMergeLocales = localizationPlugin.mergeLocales;
36
+
37
+ // Define your custom hook
38
+ function myCustomMergeLocalesHook(current, update) {
39
+ // Modify the mergedLocales data here
40
+ Object.keys(update).forEach(key => {
41
+ if (typeof current[key] === 'undefined') {
42
+ current[key] = [];
43
+ }
44
+ if (Array.isArray(current[key]) && Array.isArray(update[key])) {
45
+ if (update[key].toString().includes("venia-ui")) {
46
+ delete update[key];
47
+ }
48
+ }
49
+ });
50
+
51
+ // Return the modified mergedLocales
52
+ return originalMergeLocales.call(localizationPlugin, current, update);
53
+ }
54
+
55
+ // Override mergeLocales with your custom hook
56
+ localizationPlugin.mergeLocales = myCustomMergeLocalesHook;
57
+ }
58
+ }
59
+ });
60
+
23
61
  targets.of('@magento/pwa-buildpack').envVarDefinitions.tap(defs => {
24
62
  defs.sections.push({
25
63
  name: "Default Website Code",