@graphcommerce/next-config 7.0.0-canary.21 → 7.0.0

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.
@@ -0,0 +1,35 @@
1
+ type PathCount = { path: string; count: number }
2
+
3
+ export const packageRoots = (packagePaths: string[]): string[] => {
4
+ const pathMap: { [key: string]: PathCount } = {}
5
+
6
+ // Iterate over each path in the array
7
+ packagePaths.forEach((singlePath) => {
8
+ const parts = singlePath.split('/')
9
+
10
+ // Iterate through each part of the path
11
+ for (let i = 1; i < parts.length; i++) {
12
+ const subPath = parts.slice(0, i + 1).join('/')
13
+
14
+ // Increment the count of this subPath
15
+ if (pathMap[subPath]) {
16
+ pathMap[subPath].count += 1
17
+ } else {
18
+ pathMap[subPath] = { path: subPath, count: 1 }
19
+ }
20
+ }
21
+ })
22
+
23
+ // Filter the paths that appear more than once
24
+ const roots: string[] = []
25
+ Object.values(pathMap).forEach(({ path, count }) => {
26
+ if (count > 1) {
27
+ roots.push(path)
28
+ }
29
+ })
30
+
31
+ // Filter out the sub-paths which are part of another longer sub-path
32
+ return roots.filter(
33
+ (root, index, self) => self.findIndex((r) => r !== root && r.startsWith(`${root }/`)) === -1,
34
+ )
35
+ }
@@ -2,7 +2,6 @@ import CircularDependencyPlugin from 'circular-dependency-plugin'
2
2
  import { DuplicatesPlugin } from 'inspectpack/plugin'
3
3
  import type { NextConfig } from 'next'
4
4
  import { DomainLocale } from 'next/dist/server/config'
5
- import { RemotePattern } from 'next/dist/shared/lib/image-config'
6
5
  import { DefinePlugin, Configuration } from 'webpack'
7
6
  import { loadConfig } from './config/loadConfig'
8
7
  import { configToImportMeta } from './config/utils/configToImportMeta'
@@ -18,10 +17,10 @@ function domains(config: GraphCommerceConfig): DomainLocale[] {
18
17
  if (!loc.domain) return acc
19
18
 
20
19
  acc[loc.domain] = {
21
- defaultLocale: loc.defaultLocale ? loc.locale : acc[loc.domain]?.defaultLocale,
20
+ defaultLocale: loc.locale,
22
21
  locales: [...(acc[loc.domain]?.locales ?? []), loc.locale],
23
22
  domain: loc.domain,
24
- http: true,
23
+ http: process.env.NODE_ENV === 'development' || undefined,
25
24
  } as DomainLocale
26
25
 
27
26
  return acc
@@ -29,15 +28,6 @@ function domains(config: GraphCommerceConfig): DomainLocale[] {
29
28
  )
30
29
  }
31
30
 
32
- function remotePatterns(url: string): RemotePattern {
33
- const urlObj = new URL(url)
34
- return {
35
- hostname: urlObj.hostname,
36
- protocol: urlObj.protocol as RemotePattern['protocol'],
37
- port: urlObj.port,
38
- }
39
- }
40
-
41
31
  /**
42
32
  * GraphCommerce configuration: .
43
33
  *
@@ -61,10 +51,12 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
61
51
  return {
62
52
  ...nextConfig,
63
53
  experimental: {
64
- enableUndici: true,
65
54
  ...nextConfig.experimental,
55
+ scrollRestoration: true,
56
+ swcPlugins: [...(nextConfig.experimental?.swcPlugins ?? []), ['@lingui/swc-plugin', {}]],
66
57
  },
67
58
  i18n: {
59
+ ...nextConfig.i18n,
68
60
  defaultLocale:
69
61
  storefront.find((locale) => locale.defaultLocale)?.locale ?? storefront[0].locale,
70
62
  locales: storefront.map((locale) => locale.locale),
@@ -91,6 +83,7 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
91
83
  { source: '/product/downloadable/:url*', destination, permanent: true },
92
84
  { source: '/product/grouped/:url*', destination, permanent: true },
93
85
  { source: '/product/virtual/:url*', destination, permanent: true },
86
+ { source: '/customer/account', destination: '/account', permanent: true },
94
87
  ],
95
88
  )
96
89