@graphcommerce/next-config 8.1.0-canary.2 → 8.1.0-canary.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 (44) hide show
  1. package/CHANGELOG.md +133 -1
  2. package/Config.graphqls +4 -2
  3. package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +19 -2
  4. package/__tests__/config/utils/replaceConfigInString.ts +4 -0
  5. package/__tests__/interceptors/findPlugins.ts +473 -113
  6. package/__tests__/interceptors/generateInterceptors.ts +610 -322
  7. package/__tests__/interceptors/parseStructure.ts +158 -0
  8. package/__tests__/interceptors/writeInterceptors.ts +23 -14
  9. package/__tests__/utils/resolveDependenciesSync.ts +28 -25
  10. package/dist/config/commands/generateConfig.js +5 -2
  11. package/dist/config/demoConfig.js +19 -4
  12. package/dist/generated/config.js +8 -1
  13. package/dist/interceptors/InterceptorPlugin.js +70 -25
  14. package/dist/interceptors/RenameVisitor.js +19 -0
  15. package/dist/interceptors/Visitor.js +1418 -0
  16. package/dist/interceptors/extractExports.js +201 -0
  17. package/dist/interceptors/findOriginalSource.js +87 -0
  18. package/dist/interceptors/findPlugins.js +21 -53
  19. package/dist/interceptors/generateInterceptor.js +200 -0
  20. package/dist/interceptors/generateInterceptors.js +38 -179
  21. package/dist/interceptors/parseStructure.js +71 -0
  22. package/dist/interceptors/swc.js +16 -0
  23. package/dist/interceptors/writeInterceptors.js +19 -10
  24. package/dist/utils/resolveDependency.js +27 -5
  25. package/dist/withGraphCommerce.js +2 -1
  26. package/package.json +4 -1
  27. package/src/config/commands/generateConfig.ts +5 -2
  28. package/src/config/demoConfig.ts +19 -4
  29. package/src/config/index.ts +4 -2
  30. package/src/generated/config.ts +25 -3
  31. package/src/index.ts +16 -6
  32. package/src/interceptors/InterceptorPlugin.ts +90 -32
  33. package/src/interceptors/RenameVisitor.ts +17 -0
  34. package/src/interceptors/Visitor.ts +1847 -0
  35. package/src/interceptors/extractExports.ts +230 -0
  36. package/src/interceptors/findOriginalSource.ts +105 -0
  37. package/src/interceptors/findPlugins.ts +36 -87
  38. package/src/interceptors/generateInterceptor.ts +271 -0
  39. package/src/interceptors/generateInterceptors.ts +67 -237
  40. package/src/interceptors/parseStructure.ts +82 -0
  41. package/src/interceptors/swc.ts +13 -0
  42. package/src/interceptors/writeInterceptors.ts +26 -10
  43. package/src/utils/resolveDependency.ts +51 -12
  44. package/src/withGraphCommerce.ts +2 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,138 @@
1
1
  # Change Log
2
2
 
3
- ## 8.1.0-canary.2
3
+ ## 8.1.0-canary.5
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2226](https://github.com/graphcommerce-org/graphcommerce/pull/2226) [`8939df2`](https://github.com/graphcommerce-org/graphcommerce/commit/8939df22eda57e681f83076707e856700f8b2e21) - Big improvements to the plugin system: Typescript validated, deeper resolution, new configuration object, replace plugins, and more ifConfig options.
8
+
9
+ 1. Plugins now use TypeScript's `"moduleSuffixes": [".interceptor", ""]` [functionality](https://www.typescriptlang.org/tsconfig#moduleSuffixes) which means that plugins now correctly resolve via TypeScript. So if you _go to reference_ in VSCode (or any other editor), you go to the interceptor directly and see which plugins are applied there. This also means that plugins are automatically checked during build (and will fail if there are errors).
10
+ 2. The exported type of an _intercepted component_ now has the types of all plugins applied. This means that plugins can modify the props of components (and is still validated with TypeScript). To make this work a plugin must always forward props to the `<Prev>` to ensure that values are correctly passed on.
11
+ 3. Plugins will now always be applied to deepest resolved path. This means that a plugin automatically applies to internal usages as well. This thus means that plugins do not need to be written with an internal path, but can keep the parent path. Istead of writing `@graphcommerce/magento-cart-items/components/RemoveItemFromCart/RemoveItemFromCartFab` you can now write `@graphcommerce/magento-cart-items`.
12
+ 4. A new configuration object for plugins is created instead of separate exports (the legacy format is still supported though):
13
+
14
+ ```tsx
15
+ export const config: PluginConfig = {
16
+ type: 'component'
17
+ module: '@graphcommerce/magento-product',
18
+ ifConfig: 'demoMode',
19
+ }
20
+ ```
21
+
22
+ This also means that the _name of the export_ dictates the name of the component/function the plugin is applied.
23
+
24
+ 5. We now support replace plugins (`type: 'replace'`), which allow you to replace the original component/function/const completely (and type checked of course).
25
+
26
+ ```tsx
27
+ import { ProductPageNameProps } from "@graphcommerce/magento-product";
28
+ import { PluginConfig } from "@graphcommerce/next-config";
29
+
30
+ export const config: PluginConfig = {
31
+ type: "replace",
32
+ module: "@graphcommerce/magento-product",
33
+ };
34
+
35
+ export function ProductPageName(props: ProductPageNameProps) {
36
+ const { product } = props;
37
+ return <div>REPLACEMENT {product.url_key}</div>;
38
+ }
39
+ ```
40
+
41
+ Plugin files can now have multiple exports for the same configuration. So next to the `ProductPageName` you can also have a `ProductPagePrice` export for example in the same file.
42
+
43
+ 6. We now support `ifConfig` tuple which allows you to apply a plugin only if a certain configuration is set.
44
+
45
+ ```tsx
46
+ export const config: PluginConfig = {
47
+ type: "replace",
48
+ module: "@graphcommerce/magento-product",
49
+ ifConfig: ["theme", "my-theme"],
50
+ };
51
+ ```
52
+
53
+ This allows you to support multiple builds with different plugins applied. For example one build with `GC_THEME=my-theme` and another with `GC_THEME=my-other-theme`. ([@paales](https://github.com/paales))
54
+
55
+ ## 8.0.6-canary.4
56
+
57
+ ### Patch Changes
58
+
59
+ - [#2227](https://github.com/graphcommerce-org/graphcommerce/pull/2227) [`d597719`](https://github.com/graphcommerce-org/graphcommerce/commit/d597719baaabbe079660ac063fd021d871831511) - Added option to change sort order (ASC / DESC) for sort options (Name, price, position etc) on catalog and search pages.
60
+ ([@FrankHarland](https://github.com/FrankHarland))
61
+
62
+ ## 8.0.6-canary.3
63
+
64
+ ## 8.0.6-canary.2
65
+
66
+ ### Patch Changes
67
+
68
+ - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
69
+ ([@FrankHarland](https://github.com/FrankHarland))
70
+
71
+ ## 8.0.6-canary.1
72
+
73
+ ### Patch Changes
74
+
75
+ - [#2213](https://github.com/graphcommerce-org/graphcommerce/pull/2213) [`9b8349f`](https://github.com/graphcommerce-org/graphcommerce/commit/9b8349f0001a786f9b1666f050ae226316bd16f3) - Removed the ProductPage query from the examples directory as it isn't used anymore
76
+ ([@paales](https://github.com/paales))
77
+
78
+ ## 8.0.6-canary.0
79
+
80
+ ### Patch Changes
81
+
82
+ - [#2196](https://github.com/graphcommerce-org/graphcommerce/pull/2196) [`84c50e4`](https://github.com/graphcommerce-org/graphcommerce/commit/84c50e49a1a7f154d4a8f4045c37e773e20283ad) - Allow Lingui to use linguiLocale with country identifiers like `en-us`, it would always load `en` in this case. Introced a new `useLocale` hook to use the correct locale string to use in Intl methods.
83
+ ([@paales](https://github.com/paales))
84
+
85
+ ## 8.0.5
86
+
87
+ ### Patch Changes
88
+
89
+ - [#2236](https://github.com/graphcommerce-org/graphcommerce/pull/2236) [`1a20a34`](https://github.com/graphcommerce-org/graphcommerce/commit/1a20a34a8b55781ee3e88731b5e2623a85c64ccd) - Enable bundlePagesExternals for Vercel environments
90
+ ([@paales](https://github.com/paales))
91
+
92
+ ## 8.0.5-canary.10
93
+
94
+ ## 8.0.5-canary.9
95
+
96
+ ## 8.0.5-canary.8
97
+
98
+ ## 8.0.5-canary.7
99
+
100
+ ## 8.0.5-canary.6
101
+
102
+ ## 8.0.5-canary.5
103
+
104
+ ## 8.0.5-canary.4
105
+
106
+ ## 8.0.5-canary.3
107
+
108
+ ### Patch Changes
109
+
110
+ - [#2236](https://github.com/graphcommerce-org/graphcommerce/pull/2236) [`1a20a34`](https://github.com/graphcommerce-org/graphcommerce/commit/1a20a34a8b55781ee3e88731b5e2623a85c64ccd) - Enable bundlePagesExternals for Vercel environments
111
+ ([@paales](https://github.com/paales))
112
+
113
+ ## 8.0.5-canary.2
114
+
115
+ ## 8.0.5-canary.1
116
+
117
+ ## 8.0.5-canary.0
118
+
119
+ ## 8.0.4
120
+
121
+ ## 8.0.4-canary.1
122
+
123
+ ## 8.0.4-canary.0
124
+
125
+ ## 8.0.3
126
+
127
+ ## 8.0.3-canary.6
128
+
129
+ ## 8.0.3-canary.5
130
+
131
+ ## 8.0.3-canary.4
132
+
133
+ ## 8.0.3-canary.3
134
+
135
+ ## 8.0.3-canary.2
4
136
 
5
137
  ## 8.0.3-canary.1
6
138
 
package/Config.graphqls CHANGED
@@ -58,7 +58,7 @@ Examples:
58
58
 
59
59
  You can export configuration by running `yarn graphcommerce export-config`
60
60
 
61
- ## Extending the configuration in your project
61
+ ## Extending the configuration in your project
62
62
 
63
63
  Create a graphql/Config.graphqls file in your project and extend the GraphCommerceConfig, GraphCommerceStorefrontConfig inputs to add configuration.
64
64
 
@@ -132,7 +132,9 @@ input GraphCommerceStorefrontConfig {
132
132
  domain: String
133
133
 
134
134
  """
135
- Must be a locale string https://www.unicode.org/reports/tr35/tr35-59/tr35.html#Identifiers
135
+ Must be a [locale string](https://www.unicode.org/reports/tr35/tr35-59/tr35.html#Identifiers) for automatic redirects to work.
136
+
137
+ This value can be used as a sub-path identifier only, make sure linguiLocale is configured for each URL.
136
138
  """
137
139
  locale: String!
138
140
 
@@ -30,25 +30,43 @@ exports[`traverses a schema and returns a list of env variables that match 1`] =
30
30
  "GC_CART_DISPLAY_PRICES_INCL_TAX",
31
31
  "GC_COMPARE",
32
32
  "GC_COMPARE_VARIANT",
33
+ "GC_CONFIGURABLE_VARIANT_FOR_SIMPLE",
34
+ "GC_CONFIGURABLE_VARIANT_VALUES",
35
+ "GC_CONFIGURABLE_VARIANT_VALUES_CONTENT",
36
+ "GC_CONFIGURABLE_VARIANT_VALUES_GALLERY",
37
+ "GC_CONFIGURABLE_VARIANT_VALUES_URL",
38
+ "GC_CROSS_SELLS_HIDE_CART_ITEMS",
39
+ "GC_CROSS_SELLS_REDIRECT_ITEMS",
33
40
  "GC_CUSTOMER_REQUIRE_EMAIL_CONFIRMATION",
41
+ "GC_DATA_LAYER",
42
+ "GC_DATA_LAYER_CORE_WEB_VITALS",
34
43
  "GC_DEBUG",
35
44
  "GC_DEBUG_PLUGIN_STATUS",
45
+ "GC_DEBUG_SESSIONS",
36
46
  "GC_DEBUG_WEBPACK_CIRCULAR_DEPENDENCY_PLUGIN",
37
47
  "GC_DEBUG_WEBPACK_DUPLICATES_PLUGIN",
38
48
  "GC_DEMO_MODE",
49
+ "GC_ENABLE_GUEST_CHECKOUT_LOGIN",
39
50
  "GC_GOOGLE_ANALYTICS_ID",
40
51
  "GC_GOOGLE_RECAPTCHA_KEY",
41
52
  "GC_GOOGLE_TAGMANAGER_ID",
42
53
  "GC_HYGRAPH_ENDPOINT",
54
+ "GC_HYGRAPH_MANAGEMENT_API",
55
+ "GC_HYGRAPH_PROJECT_ID",
43
56
  "GC_HYGRAPH_WRITE_ACCESS_ENDPOINT",
44
57
  "GC_HYGRAPH_WRITE_ACCESS_TOKEN",
45
- "GC_LEGACY_PRODUCT_ROUTE",
46
58
  "GC_LIMIT_SSG",
47
59
  "GC_MAGENTO_ENDPOINT",
48
60
  "GC_PREVIEW_SECRET",
61
+ "GC_PRODUCT_FILTERS_LAYOUT",
49
62
  "GC_PRODUCT_FILTERS_PRO",
50
63
  "GC_PRODUCT_ROUTE",
64
+ "GC_RECENTLY_VIEWED_PRODUCTS",
65
+ "GC_RECENTLY_VIEWED_PRODUCTS_ENABLED",
66
+ "GC_RECENTLY_VIEWED_PRODUCTS_MAX_COUNT",
51
67
  "GC_ROBOTS_ALLOW",
68
+ "GC_SIDEBAR_GALLERY",
69
+ "GC_SIDEBAR_GALLERY_PAGINATION_VARIANT",
52
70
  "GC_STOREFRONT",
53
71
  "GC_STOREFRONT_0",
54
72
  "GC_STOREFRONT_0_CANONICAL_BASE_URL",
@@ -744,7 +762,6 @@ exports[`traverses a schema and returns a list of env variables that match 1`] =
744
762
  "GC_STOREFRONT_20_LOCALE",
745
763
  "GC_STOREFRONT_20_MAGENTO_STORE_CODE",
746
764
  "GC_WISHLIST_HIDE_FOR_GUESTS",
747
- "GC_WISHLIST_IGNORE_PRODUCT_WISHLIST_STATUS",
748
765
  "GC_WISHLIST_SHOW_FEEDBACK_MESSAGE",
749
766
  ]
750
767
  `;
@@ -57,20 +57,24 @@ it('replaces config in string', () => {
57
57
  },
58
58
  {
59
59
  "cartDisplayPricesInclTax": true,
60
+ "linguiLocale": "fr",
60
61
  "locale": "fr-be",
61
62
  "magentoStoreCode": "fr_BE",
62
63
  },
63
64
  {
64
65
  "cartDisplayPricesInclTax": true,
66
+ "linguiLocale": "nl",
65
67
  "locale": "nl-be",
66
68
  "magentoStoreCode": "nl_BE",
67
69
  },
68
70
  {
69
71
  "cartDisplayPricesInclTax": true,
72
+ "linguiLocale": "en",
70
73
  "locale": "en-gb",
71
74
  "magentoStoreCode": "en_GB",
72
75
  },
73
76
  {
77
+ "linguiLocale": "en",
74
78
  "locale": "en-ca",
75
79
  "magentoStoreCode": "en_CA",
76
80
  },