@graphcommerce/next-config 9.1.0-canary.55 → 10.0.0-canary.56

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 (35) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/Config.graphqls +3 -3
  3. package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +1 -1
  4. package/__tests__/interceptors/generateInterceptors.ts +133 -150
  5. package/dist/config/loadConfig.js +7 -0
  6. package/dist/generated/config.js +9 -9
  7. package/dist/index.js +804 -2436
  8. package/dist/loadConfig-nJiCKeL1.js +311 -0
  9. package/dist/utils/findParentPath.js +36 -0
  10. package/package.json +41 -20
  11. package/src/commands/cleanupInterceptors.ts +26 -0
  12. package/src/commands/codegen.ts +13 -15
  13. package/src/commands/codegenInterceptors.ts +31 -0
  14. package/src/{config/commands → commands}/exportConfig.ts +3 -3
  15. package/src/{config/commands → commands}/generateConfig.ts +12 -9
  16. package/src/commands/generateConfigValues.ts +265 -0
  17. package/src/commands/index.ts +7 -0
  18. package/src/config/index.ts +0 -9
  19. package/src/config/loadConfig.ts +0 -1
  20. package/src/config/utils/mergeEnvIntoConfig.ts +27 -4
  21. package/src/generated/config.ts +13 -14
  22. package/src/index.ts +7 -39
  23. package/src/interceptors/generateInterceptor.ts +192 -157
  24. package/src/interceptors/generateInterceptors.ts +9 -2
  25. package/src/interceptors/updatePackageExports.ts +147 -0
  26. package/src/interceptors/writeInterceptors.ts +90 -35
  27. package/src/types.ts +26 -0
  28. package/src/utils/index.ts +7 -0
  29. package/src/utils/resolveDependenciesSync.ts +5 -7
  30. package/src/withGraphCommerce.ts +30 -49
  31. package/tsconfig.json +3 -1
  32. package/__tests__/config/utils/configToImportMeta.ts +0 -121
  33. package/src/interceptors/InterceptorPlugin.ts +0 -141
  34. package/src/interceptors/commands/codegenInterceptors.ts +0 -27
  35. /package/src/utils/{isMonorepo.ts → findParentPath.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,85 @@
1
1
  # Change Log
2
2
 
3
+ ## 10.0.0-canary.56
4
+
5
+ ### Major Changes
6
+
7
+ - [#2546](https://github.com/graphcommerce-org/graphcommerce/pull/2546) [`ed9332a`](https://github.com/graphcommerce-org/graphcommerce/commit/ed9332a7f78966d932041d9a7725641edc92b28d) - ## GraphCommerce 10 - Turbopack Support
8
+
9
+ This major release brings full Turbopack compatibility, dramatically improving development speed.
10
+
11
+ ### 🚀 Turbopack-Compatible Interceptor System
12
+
13
+ The entire plugin/interceptor system has been rewritten to work with Turbopack:
14
+
15
+ - **No more Webpack plugins** - Removed `InterceptorPlugin` webpack plugin entirely
16
+ - **File-based interception** - Original files are moved to `.original.tsx` and replaced with interceptor content
17
+ - **Direct imports** - Interceptors import from `.original` files instead of embedding source
18
+ - **New CLI commands**:
19
+ - `graphcommerce codegen-interceptors` - Generate interceptor files
20
+ - `graphcommerce cleanup-interceptors` - Reset interceptor system, restore original files
21
+ - **Stable file hashing** - Deterministic interceptor generation for better caching
22
+
23
+ ### ⚙️ Treeshakable Configuration System
24
+
25
+ Replaced Webpack `DefinePlugin`-based `import.meta.graphCommerce` with a new generated configuration system:
26
+
27
+ - **New `codegen-config-values` command** - Generates TypeScript files with precise typing
28
+ - **Schema-driven** - Dynamically introspects Zod schemas to determine all available properties
29
+ - **Fully treeshakable** - Unused config values are eliminated from the bundle
30
+ - **Type-safe** - Uses `Get<GraphCommerceConfig, 'path'>` for nested property access
31
+ - **Separate files for nested objects** - Optimal treeshaking for complex configurations
32
+
33
+ ### 🔧 withGraphCommerce Changes
34
+
35
+ - **Removed** `InterceptorPlugin` - No longer needed with file-based interception
36
+ - **Removed** `DefinePlugin` for `import.meta.graphCommerce` - Replaced with generated config
37
+ - **Removed** `@mui/*` alias rewrites - No longer required
38
+ - **Added** Turbopack loader rules for `.yaml`, `.yml`, and `.po` files
39
+ - **Added** `serverExternalPackages` for all `@whatwg-node/*` packages
40
+ - **Added** `optimizePackageImports` for better bundle optimization
41
+ - **Added** `images.qualities: [52, 75]` for Next.js image optimization
42
+
43
+ ### 📦 Lingui Configuration
44
+
45
+ - **Renamed** `lingui.config.js` → `lingui.config.ts` with TypeScript support
46
+ - **Updated** `@graphcommerce/lingui-next/config` to TypeScript with proper exports
47
+ - **Simplified** formatter options
48
+
49
+ ### ⚛️ React 19 & Next.js 16 Compatibility
50
+
51
+ - Updated `RefObject<T>` types for React 19 (now includes `null` by default)
52
+ - Replaced deprecated `React.VFC` with `React.FC`
53
+ - Fixed `useRef` calls to require explicit initial values
54
+ - Updated `MutableRefObject` usage in `framer-scroller`
55
+
56
+ ### 📋 ESLint 9 Flat Config
57
+
58
+ - Migrated from legacy `.eslintrc` to new flat config format (`eslint.config.mjs`)
59
+ - Updated `@typescript-eslint/*` packages to v8
60
+ - Fixed AST selector for `SxProps` rule (`typeParameters` → `typeArguments`)
61
+
62
+ ### 🔄 Apollo Client
63
+
64
+ - Fixed deprecated `name` option → `clientAwareness: { name: 'ssr' }`
65
+ - Updated error handling types to accept `ApolloError | null | undefined`
66
+
67
+ ### ⚠️ Breaking Changes
68
+
69
+ - **Node.js 24.x not supported** - Restricted to `>=20 <24.0.0` due to [nodejs/undici#4290](https://github.com/nodejs/undici/issues/4290)
70
+ - **Interceptor files changed** - Original components now at `.original.tsx`
71
+ - **Config access changed** - Use generated config values instead of `import.meta.graphCommerce`
72
+ - **ESLint config format** - Must use flat config (`eslint.config.mjs`)
73
+ - **Lingui config** - Rename `lingui.config.js` to `lingui.config.ts`
74
+
75
+ ### 🗑️ Removed
76
+
77
+ - `InterceptorPlugin` webpack plugin
78
+ - `configToImportMeta` utility
79
+ - Webpack `DefinePlugin` usage for config
80
+ - `@mui/*` modern alias rewrites
81
+ - Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
82
+
3
83
  ## 9.1.0-canary.55
4
84
 
5
85
  ## 9.1.0-canary.54
package/Config.graphqls CHANGED
@@ -14,9 +14,9 @@ Configuration can be accessed in your project with the `import.meta.graphCommerc
14
14
 
15
15
  ```tsx
16
16
  import { storefrontAll, storefrontConfig, storefrontConfigDefault, useStorefrontConfig } from '@graphcommerce/next-ui'
17
-
17
+ import { cartDisplayPricesInclTax } from '@graphcommerce/next-config/config'
18
18
  // Accessing a global value
19
- const globalConf = import.meta.graphCommerce.cartDisplayPricesInclTax
19
+ const globalConf = cartDisplayPricesInclTax
20
20
 
21
21
  function MyComponent() {
22
22
  // Configuration configured per storefront locale.
@@ -27,7 +27,7 @@ function MyComponent() {
27
27
 
28
28
  // Or as single line
29
29
  const scopedConfigWithFallback2 =
30
- useStorefrontConfig().cartDisplayPricesInclTax ?? import.meta.graphCommerce.cartDisplayPricesInclTax
30
+ useStorefrontConfig().cartDisplayPricesInclTax ?? cartDisplayPricesInclTax
31
31
 
32
32
  return <div>{googleRecaptchaKey}</div>
33
33
  }
@@ -1,4 +1,4 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
2
 
3
3
  exports[`parses an env config object 1`] = `
4
4
  {
@@ -1,29 +1,15 @@
1
1
  import type { GraphCommerceConfig } from '../../src/generated/config'
2
2
  import { findOriginalSource } from '../../src/interceptors/findOriginalSource'
3
- import { SOURCE_END, SOURCE_START } from '../../src/interceptors/generateInterceptor'
4
3
  import { generateInterceptors } from '../../src/interceptors/generateInterceptors'
5
4
  import { parseStructure } from '../../src/interceptors/parseStructure'
6
5
  import { parseSync } from '../../src/interceptors/swc'
7
6
  import { resolveDependency } from '../../src/utils/resolveDependency'
8
7
 
9
8
  const projectRoot = `${process.cwd()}/examples/magento-graphcms`
10
- const startLocation = '/** @see {@link file://'
11
- const expectImport = (value: string | undefined): jest.JestMatchers<string> =>
12
- expect(value?.slice(value.indexOf('import') - 1, value.indexOf(startLocation) - 1).trim())
13
- const expectInterceptor = (value: string | undefined): jest.JestMatchers<string> => {
14
- const val = value?.slice(value.indexOf(SOURCE_END) + SOURCE_END.length).trim()
15
- return expect(val?.trim())
16
- }
17
- const expectOriginal = (value: string | undefined): jest.JestMatchers<string> =>
18
- expect(
19
- value
20
- ?.slice(value.indexOf(SOURCE_START) + SOURCE_START.length, value.indexOf(SOURCE_END))
21
- .trim(),
22
- )
23
9
  it('it replaces paths and creates a relative path', () => {
24
10
  const resolver = resolveDependency(projectRoot)
25
11
  const resolved = resolver('@graphcommerce/magento-cart-payment-method')
26
- expect(resolved?.fromRoot).toMatchInlineSnapshot('"packages/magento-cart-payment-method/index"')
12
+ expect(resolved?.fromRoot).toMatchInlineSnapshot(`"packages/magento-cart-payment-method/index"`)
27
13
  expect(resolved?.fromModule).toBe('.')
28
14
  expect(resolved?.root).toBe('packages/magento-cart-payment-method')
29
15
  const resolved2 = resolver(
@@ -64,8 +50,19 @@ it('it generates an interceptor', async () => {
64
50
  const result =
65
51
  interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
66
52
  ?.template
67
- expectInterceptor(result).toMatchInlineSnapshot(`
68
- "type PluginAddBraintreeMethodsProps = OmitPrev<
53
+ expect(result).toMatchInlineSnapshot(`
54
+ "/* hash:2187222972 */
55
+ /* eslint-disable */
56
+ /* This file is automatically generated for @graphcommerce/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext */
57
+ import { Plugin as PluginAddBraintreeMethods } from '@graphcommerce/magento-payment-braintree/plugins/AddBraintreeMethods'
58
+ import { Plugin as PluginAddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'
59
+ import type { DistributedOmit as OmitPrev } from 'type-fest'
60
+ import { PaymentMethodContextProvider as PaymentMethodContextProviderOriginal } from './PaymentMethodContext.original'
61
+
62
+ // Re-export everything from the original file except the intercepted exports
63
+ export * from './PaymentMethodContext.original'
64
+
65
+ type PluginAddBraintreeMethodsProps = OmitPrev<
69
66
  React.ComponentProps<typeof PluginAddBraintreeMethods>,
70
67
  'Prev'
71
68
  >
@@ -74,8 +71,10 @@ it('it generates an interceptor', async () => {
74
71
  <PluginAddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
75
72
  )
76
73
 
77
- type PluginAddMollieMethodsProps = PluginAddBraintreeMethodsProps &
78
- OmitPrev<React.ComponentProps<typeof PluginAddMollieMethods>, 'Prev'>
74
+ type PluginAddMollieMethodsProps = OmitPrev<
75
+ React.ComponentProps<typeof PluginAddMollieMethods>,
76
+ 'Prev'
77
+ >
79
78
 
80
79
  const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
81
80
  <PluginAddMollieMethods {...props} Prev={PluginAddBraintreeMethodsInterceptor} />
@@ -87,11 +86,12 @@ it('it generates an interceptor', async () => {
87
86
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
88
87
  * original source changes.
89
88
  *
90
- * @see {@link file://./PaymentMethodContext.tsx} for original source file
89
+ * @see {@link file://./PaymentMethodContextProvider.tsx} for original source file
91
90
  * @see {PluginAddBraintreeMethods} for source of applied plugin
92
91
  * @see {PluginAddMollieMethods} for source of applied plugin
93
92
  */
94
- export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor"
93
+ export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor
94
+ "
95
95
  `)
96
96
  })
97
97
  it("resolves a 'root plugin' to be relative to the interceptor", async () => {
@@ -109,7 +109,7 @@ it("resolves a 'root plugin' to be relative to the interceptor", async () => {
109
109
  resolveDependency(projectRoot),
110
110
  )
111
111
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
112
- '"packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext"',
112
+ `"packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext"`,
113
113
  )
114
114
  expect(
115
115
  interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
@@ -150,9 +150,20 @@ it('it can apply multiple plugins to a single export', async () => {
150
150
  expect(result).toContain(
151
151
  "import { Plugin as PluginAddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'",
152
152
  )
153
- expectOriginal(result).toContain('PaymentMethodContextProviderOriginal')
154
- expectInterceptor(result).toMatchInlineSnapshot(`
155
- "type PluginAddAdyenMethodsProps = OmitPrev<
153
+ expect(result).toContain('PaymentMethodContextProviderOriginal')
154
+ expect(result).toMatchInlineSnapshot(`
155
+ "/* hash:37369946 */
156
+ /* eslint-disable */
157
+ /* This file is automatically generated for @graphcommerce/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext */
158
+ import { Plugin as PluginAddAdyenMethods } from '@graphcommerce/magento-payment-adyen/plugins/AddAdyenMethods'
159
+ import { Plugin as PluginAddMollieMethods } from '@graphcommerce/mollie-magento-payment/plugins/AddMollieMethods'
160
+ import type { DistributedOmit as OmitPrev } from 'type-fest'
161
+ import { PaymentMethodContextProvider as PaymentMethodContextProviderOriginal } from './PaymentMethodContext.original'
162
+
163
+ // Re-export everything from the original file except the intercepted exports
164
+ export * from './PaymentMethodContext.original'
165
+
166
+ type PluginAddAdyenMethodsProps = OmitPrev<
156
167
  React.ComponentProps<typeof PluginAddAdyenMethods>,
157
168
  'Prev'
158
169
  >
@@ -161,8 +172,10 @@ it('it can apply multiple plugins to a single export', async () => {
161
172
  <PluginAddAdyenMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
162
173
  )
163
174
 
164
- type PluginAddMollieMethodsProps = PluginAddAdyenMethodsProps &
165
- OmitPrev<React.ComponentProps<typeof PluginAddMollieMethods>, 'Prev'>
175
+ type PluginAddMollieMethodsProps = OmitPrev<
176
+ React.ComponentProps<typeof PluginAddMollieMethods>,
177
+ 'Prev'
178
+ >
166
179
 
167
180
  const PluginAddMollieMethodsInterceptor = (props: PluginAddMollieMethodsProps) => (
168
181
  <PluginAddMollieMethods {...props} Prev={PluginAddAdyenMethodsInterceptor} />
@@ -174,11 +187,12 @@ it('it can apply multiple plugins to a single export', async () => {
174
187
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
175
188
  * original source changes.
176
189
  *
177
- * @see {@link file://./PaymentMethodContext.tsx} for original source file
190
+ * @see {@link file://./PaymentMethodContextProvider.tsx} for original source file
178
191
  * @see {PluginAddAdyenMethods} for source of applied plugin
179
192
  * @see {PluginAddMollieMethods} for source of applied plugin
180
193
  */
181
- export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor"
194
+ export const PaymentMethodContextProvider = PluginAddMollieMethodsInterceptor
195
+ "
182
196
  `)
183
197
  })
184
198
  it('it handles on duplicates gracefully', async () => {
@@ -207,8 +221,18 @@ it('it handles on duplicates gracefully', async () => {
207
221
  const result =
208
222
  interceptors['packages/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext']
209
223
  ?.template
210
- expectInterceptor(result).toMatchInlineSnapshot(`
211
- "type PluginAddBraintreeMethodsProps = OmitPrev<
224
+ expect(result).toMatchInlineSnapshot(`
225
+ "/* hash:1530081422 */
226
+ /* eslint-disable */
227
+ /* This file is automatically generated for @graphcommerce/magento-cart-payment-method/PaymentMethodContext/PaymentMethodContext */
228
+ import { Plugin as PluginAddBraintreeMethods } from '@graphcommerce/magento-payment-braintree/plugins/AddBraintreeMethods'
229
+ import type { DistributedOmit as OmitPrev } from 'type-fest'
230
+ import { PaymentMethodContextProvider as PaymentMethodContextProviderOriginal } from './PaymentMethodContext.original'
231
+
232
+ // Re-export everything from the original file except the intercepted exports
233
+ export * from './PaymentMethodContext.original'
234
+
235
+ type PluginAddBraintreeMethodsProps = OmitPrev<
212
236
  React.ComponentProps<typeof PluginAddBraintreeMethods>,
213
237
  'Prev'
214
238
  >
@@ -217,16 +241,27 @@ it('it handles on duplicates gracefully', async () => {
217
241
  <PluginAddBraintreeMethods {...props} Prev={PaymentMethodContextProviderOriginal} />
218
242
  )
219
243
 
244
+ type PluginAddBraintreeMethodsProps = OmitPrev<
245
+ React.ComponentProps<typeof PluginAddBraintreeMethods>,
246
+ 'Prev'
247
+ >
248
+
249
+ const PluginAddBraintreeMethodsInterceptor = (props: PluginAddBraintreeMethodsProps) => (
250
+ <PluginAddBraintreeMethods {...props} Prev={PluginAddBraintreeMethodsInterceptor} />
251
+ )
252
+
220
253
  /**
221
254
  * Here you see the 'interceptor' that is applying all the configured plugins.
222
255
  *
223
256
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
224
257
  * original source changes.
225
258
  *
226
- * @see {@link file://./PaymentMethodContext.tsx} for original source file
259
+ * @see {@link file://./PaymentMethodContextProvider.tsx} for original source file
260
+ * @see {PluginAddBraintreeMethods} for source of applied plugin
227
261
  * @see {PluginAddBraintreeMethods} for source of applied plugin
228
262
  */
229
- export const PaymentMethodContextProvider = PluginAddBraintreeMethodsInterceptor"
263
+ export const PaymentMethodContextProvider = PluginAddBraintreeMethodsInterceptor
264
+ "
230
265
  `)
231
266
  })
232
267
  it('correctly renames all variable usages', async () => {
@@ -245,12 +280,14 @@ it('correctly renames all variable usages', async () => {
245
280
  resolve,
246
281
  )
247
282
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
248
- '"packages/ecommerce-ui/components/ApolloError/ApolloErrorAlert"',
283
+ `"packages/ecommerce-ui/components/ApolloError/ApolloErrorAlert"`,
249
284
  )
250
285
  const template =
251
286
  interceptors['packages/ecommerce-ui/components/ApolloError/ApolloErrorAlert']?.template
252
- expectOriginal(template).not.toContain('ApolloErrorAlert.selectors')
253
- expectOriginal(template).toContain('ApolloErrorAlertOriginal.selectors')
287
+ // In the new system, original code is moved to separate .original files
288
+ // We just verify that the interceptor was generated correctly
289
+ expect(template).toContain('ApolloErrorAlertOriginal')
290
+ expect(template).toContain("export * from './ApolloErrorAlert.original'")
254
291
  })
255
292
  it('it handles root plugins', async () => {
256
293
  const resolve = resolveDependency(projectRoot)
@@ -287,7 +324,7 @@ it('it handles root plugins and creates a relative path', async () => {
287
324
  resolve,
288
325
  )
289
326
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
290
- '"packages/next-ui/Overlay/components/OverlayBase"',
327
+ `"packages/next-ui/Overlay/components/OverlayBase"`,
291
328
  )
292
329
  expect(
293
330
  interceptors['packages/next-ui/Overlay/components/OverlayBase'].targetExports.OverlayBase[0]
@@ -325,14 +362,12 @@ it('generates method interceptors alognside component interceptors', async () =>
325
362
  ],
326
363
  resolve,
327
364
  )
328
- expect(Object.keys(interceptors)).toMatchInlineSnapshot(
329
- `
365
+ expect(Object.keys(interceptors)).toMatchInlineSnapshot(`
330
366
  [
331
367
  "packages/graphql/components/GraphQLProvider/GraphQLProvider",
332
368
  "packages/graphql/config",
333
369
  ]
334
- `,
335
- )
370
+ `)
336
371
  expect(
337
372
  interceptors['packages/graphql/components/GraphQLProvider/GraphQLProvider']?.template,
338
373
  ).toContain('MagentoGraphqlGraphqlProvider')
@@ -371,63 +406,24 @@ it('adds debug logging to interceptors for components', async () => {
371
406
  resolve,
372
407
  { pluginStatus: true },
373
408
  )
374
- expectImport(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
375
- "import { plugin as pluginhygraphInitMemoryCache } from '@graphcommerce/magento-graphcms/plugins/hygraphInitMemoryCache'
376
- import { plugin as pluginmagentoInitMemoryCache } from '@graphcommerce/magento-graphql/plugins/magentoInitMemoryCache'"
377
- `)
378
- expectOriginal(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
379
- "import type { GraphCommerceStorefrontConfig } from '@graphcommerce/next-config'
380
- import type { ApolloLink, TypePolicies } from '@apollo/client'
381
- import type { SetRequired } from 'type-fest'
382
- import type { MigrateCache } from './components/GraphQLProvider/migrateCache'
383
- import { RemovePrivateContextDirectivesLink } from './link/RemovePrivateContextDirectivesLink'
384
-
385
- export interface PreviewData {}
386
- export type PreviewConfig = {
387
- preview?: boolean
388
- previewData?: PreviewData & Record<string, unknown>
389
- }
390
- export type ApolloClientConfigInput = {
391
- storefront: GraphCommerceStorefrontConfig
392
- links?: ApolloLink[]
393
- policies?: TypePolicies[]
394
- migrations?: MigrateCache[]
395
- } & PreviewConfig
396
- export type ApolloClientConfig = SetRequired<
397
- ApolloClientConfigInput,
398
- 'links' | 'policies' | 'migrations'
399
- >
400
- export function graphqlConfigOriginal(config: ApolloClientConfigInput): ApolloClientConfig {
401
- const { storefront, links = [], policies = [], migrations = [], ...rest } = config
402
- return {
403
- storefront,
404
- links: [...links, new RemovePrivateContextDirectivesLink()],
405
- policies,
406
- migrations,
407
- ...rest,
408
- }
409
- }"
410
- `)
411
- expectInterceptor(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
412
- "const logged: Set<string> = new Set()
413
- const logOnce = (log: string, ...additional: unknown[]) => {
414
- if (logged.has(log)) return
415
- logged.add(log)
416
- console.warn(log, ...additional)
417
- }
409
+ expect(interceptors['packages/graphql/config']?.template).toMatchInlineSnapshot(`
410
+ "/* hash:139716906 */
411
+ /* eslint-disable */
412
+ /* This file is automatically generated for @graphcommerce/graphql/config */
413
+
414
+ import { plugin as pluginhygraphInitMemoryCache } from '@graphcommerce/magento-graphcms/plugins/hygraphInitMemoryCache'
415
+ import { plugin as pluginmagentoInitMemoryCache } from '@graphcommerce/magento-graphql/plugins/magentoInitMemoryCache'
416
+ import { graphqlConfig as graphqlConfigOriginal } from './config.original'
417
+
418
+ // Re-export everything from the original file except the intercepted exports
419
+ export * from './config.original'
418
420
 
419
421
  const pluginhygraphInitMemoryCacheInterceptor: typeof graphqlConfigOriginal = (...args) => {
420
- logOnce(
421
- \`🔌 Calling graphqlConfig with plugin(s): pluginmagentoInitMemoryCache wrapping pluginhygraphInitMemoryCache wrapping graphqlConfig()\`,
422
- )
423
422
  return pluginhygraphInitMemoryCache(graphqlConfigOriginal, ...args)
424
423
  }
425
424
  const pluginmagentoInitMemoryCacheInterceptor: typeof pluginhygraphInitMemoryCacheInterceptor = (
426
425
  ...args
427
426
  ) => {
428
- logOnce(
429
- \`🔌 Calling graphqlConfig with plugin(s): pluginhygraphInitMemoryCache wrapping pluginmagentoInitMemoryCache wrapping graphqlConfig()\`,
430
- )
431
427
  return pluginmagentoInitMemoryCache(pluginhygraphInitMemoryCacheInterceptor, ...args)
432
428
  }
433
429
 
@@ -437,11 +433,12 @@ it('adds debug logging to interceptors for components', async () => {
437
433
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
438
434
  * original source changes.
439
435
  *
440
- * @see {@link file://./config.ts} for original source file
436
+ * @see {@link file://./graphqlConfig.ts} for original source file
441
437
  * @see {pluginhygraphInitMemoryCache} for source of applied plugin
442
438
  * @see {pluginmagentoInitMemoryCache} for source of applied plugin
443
439
  */
444
- export const graphqlConfig = pluginmagentoInitMemoryCacheInterceptor"
440
+ export const graphqlConfig = pluginmagentoInitMemoryCacheInterceptor
441
+ "
445
442
  `)
446
443
  })
447
444
  it('correctly resolves when a source can not be parsed', async () => {
@@ -461,7 +458,7 @@ it('correctly resolves when a source can not be parsed', async () => {
461
458
  { pluginStatus: true },
462
459
  )
463
460
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
464
- '"packages/next-ui/Row/RowLinks/RowLinks"',
461
+ `"packages/next-ui/Row/RowLinks/RowLinks"`,
465
462
  )
466
463
  })
467
464
  it('can correctly find the source for deeper chained exports', () => {
@@ -499,7 +496,7 @@ it('Should apply overrides to the correct file', async () => {
499
496
  resolve,
500
497
  )
501
498
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
502
- '"packages/magento-product/components/ProductStaticPaths/getProductStaticPaths"',
499
+ `"packages/magento-product/components/ProductStaticPaths/getProductStaticPaths"`,
503
500
  )
504
501
  const result =
505
502
  interceptors['packages/magento-product/components/ProductStaticPaths/getProductStaticPaths']
@@ -507,7 +504,6 @@ it('Should apply overrides to the correct file', async () => {
507
504
  expect(result).toContain(
508
505
  "import { getProductStaticPaths as getProductStaticPathsreplaceGetProductStaticPaths } from '../../../../plugins/replaceGetProductStaticPaths'",
509
506
  )
510
- expectOriginal(result).toContain('getProductStaticPathsDisabled')
511
507
  })
512
508
  it('correctly reports an error for an incorrect export', async () => {
513
509
  const fakeconfig = {
@@ -582,8 +578,7 @@ export const Plugin = ConfigurableProductPageName
582
578
  '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName',
583
579
  )
584
580
  const plugins = [...firstFile, ...secondFile]
585
- expect(plugins).toMatchInlineSnapshot(
586
- `
581
+ expect(plugins).toMatchInlineSnapshot(`
587
582
  [
588
583
  {
589
584
  "enabled": true,
@@ -604,33 +599,28 @@ export const Plugin = ConfigurableProductPageName
604
599
  "type": "component",
605
600
  },
606
601
  ]
607
- `,
608
- )
602
+ `)
609
603
  const interceptors = await generateInterceptors(plugins, resolveDependency(projectRoot))
610
604
  expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(
611
- '"packages/magento-product/components/ProductPageName/ProductPageName"',
605
+ `"packages/magento-product/components/ProductPageName/ProductPageName"`,
612
606
  )
613
607
  const result =
614
608
  interceptors['packages/magento-product/components/ProductPageName/ProductPageName']?.template
615
- expectImport(result).toMatchInlineSnapshot(`
616
- "import { Plugin as PluginConfigurableProductPageName } from '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName'
609
+ expect(result).toMatchInlineSnapshot(`
610
+ "/* hash:71398615 */
611
+ /* eslint-disable */
612
+ /* This file is automatically generated for @graphcommerce/magento-product/components/ProductPageName/ProductPageName */
613
+ import { Plugin as PluginConfigurableProductPageName } from '@graphcommerce/magento-product-configurable/plugins/ConfigurableProductPage/ConfigurableProductPageName'
617
614
  import type { DistributedOmit as OmitPrev } from 'type-fest'
618
- import { ProductPageName as ProductPageNameMyPlugin } from '../../../../plugins/MyPlugin'"
619
- `)
620
- expectOriginal(result).toMatchInlineSnapshot(`
621
- "import type { ProductPageNameFragment } from './ProductPageName.gql'
615
+ import { ProductPageName as ProductPageNameMyPlugin } from '../../../../plugins/MyPlugin'
622
616
 
623
- export type ProductPageNameProps = {
624
- product: ProductPageNameFragment
625
- }
626
- export function ProductPageNameDisabled(props: ProductPageNameProps) {
627
- const { product } = props
628
- return <>{product.name}</>
629
- }"
630
- `)
631
- expectInterceptor(result).toMatchInlineSnapshot(`
632
- "type PluginConfigurableProductPageNameProps = React.ComponentProps<typeof ProductPageNameMyPlugin> &
633
- OmitPrev<React.ComponentProps<typeof PluginConfigurableProductPageName>, 'Prev'>
617
+ // Re-export everything from the original file except the intercepted exports
618
+ export * from './ProductPageName.original'
619
+
620
+ type PluginConfigurableProductPageNameProps = OmitPrev<
621
+ React.ComponentProps<typeof PluginConfigurableProductPageName>,
622
+ 'Prev'
623
+ >
634
624
 
635
625
  const PluginConfigurableProductPageNameInterceptor = (
636
626
  props: PluginConfigurableProductPageNameProps,
@@ -642,11 +632,11 @@ export const Plugin = ConfigurableProductPageName
642
632
  * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
643
633
  * original source changes.
644
634
  *
645
- * @see {@link file://./ProductPageName.tsx} for original source file
646
- * @see {ProductPageNameMyPlugin} for replacement of the original source (original source not used)
635
+ * @see {ProductPageNameMyPlugin} for source of replaced component
647
636
  * @see {PluginConfigurableProductPageName} for source of applied plugin
648
637
  */
649
- export const ProductPageName = PluginConfigurableProductPageNameInterceptor"
638
+ export const ProductPageName = PluginConfigurableProductPageNameInterceptor
639
+ "
650
640
  `)
651
641
  })
652
642
  it('generates to a .ts file when the target file is a .ts as well', async () => {
@@ -664,7 +654,7 @@ it('generates to a .ts file when the target file is a .ts as well', async () =>
664
654
  ],
665
655
  resolve,
666
656
  )
667
- expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot('"packages/graphql/config"')
657
+ expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(`"packages/graphql/config"`)
668
658
  const interceptor = interceptors['packages/graphql/config']
669
659
  expect(interceptor.sourcePath).toBe('packages/graphql/config.ts')
670
660
  })
@@ -691,37 +681,30 @@ it('Can correctly find exports that are default exports', async () => {
691
681
  } as unknown as GraphCommerceConfig
692
682
  const plugins = parseStructure(parseSync(pluginSource), config, './plugins/MyProjectIcon')
693
683
  const interceptors = await generateInterceptors(plugins, resolveDependency(projectRoot))
694
- expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot('"packages/next-ui/icons"')
684
+ expect(Object.keys(interceptors)[0]).toMatchInlineSnapshot(`"packages/next-ui/icons"`)
695
685
  const result = interceptors['packages/next-ui/icons']?.template
696
- expectImport(result).toMatchInlineSnapshot(`
697
- "import {
686
+ expect(result).toMatchInlineSnapshot(`
687
+ "/* hash:2698946304 */
688
+ /* eslint-disable */
689
+ /* This file is automatically generated for @graphcommerce/next-ui/icons */
690
+
691
+ import {
698
692
  iconChevronLeft as iconChevronLeftMyProjectIcon,
699
693
  iconChevronRight as iconChevronRightMyProjectIcon,
700
- } from '../../plugins/MyProjectIcon'"
701
- `)
702
- expectOriginal(result).toContain('iconChevronLeftDisabled')
703
- expectOriginal(result).toContain('iconChevronRightDisabled')
704
- expectInterceptor(result).toMatchInlineSnapshot(`
705
- "/**
706
- * Here you see the 'interceptor' that is applying all the configured plugins.
707
- *
708
- * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
709
- * original source changes.
710
- *
711
- * @see {@link file://./icons.ts} for original source file
712
- * @see {iconChevronLeftMyProjectIcon} for replacement of the original source (original source not used)
713
- */
714
- export const iconChevronLeft = iconChevronLeftMyProjectIcon
694
+ } from '../../plugins/MyProjectIcon'
715
695
 
716
- /**
717
- * Here you see the 'interceptor' that is applying all the configured plugins.
718
- *
719
- * This file is NOT meant to be modified directly and is auto-generated if the plugins or the
720
- * original source changes.
721
- *
722
- * @see {@link file://./icons.ts} for original source file
723
- * @see {iconChevronRightMyProjectIcon} for replacement of the original source (original source not used)
724
- */
725
- export const iconChevronRight = iconChevronRightMyProjectIcon"
696
+ // Re-export everything from the original file except the intercepted exports
697
+ export * from './icons.original'
698
+
699
+ export { iconChevronLeft as iconChevronLeft } from '../../plugins/MyProjectIcon'
700
+
701
+ export { iconChevronRight as iconChevronRight } from '../../plugins/MyProjectIcon'
702
+ "
726
703
  `)
704
+ // In the new system, original exports like iconChevronLeftDisabled are in the .original file
705
+ // The interceptor should export * from the original to re-export them
706
+ expect(result).toContain("export * from './icons.original'")
707
+ expect(result).toContain(
708
+ "export { iconChevronLeft as iconChevronLeft } from '../../plugins/MyProjectIcon'",
709
+ )
727
710
  })
@@ -0,0 +1,7 @@
1
+ import 'cosmiconfig';
2
+ import '../generated/config.js';
3
+ export { l as loadConfig, r as replaceConfigInString } from '../loadConfig-nJiCKeL1.js';
4
+ import 'zod';
5
+ import '@apollo/client/utilities/index.js';
6
+ import 'chalk';
7
+ import 'lodash';