From d712e517b06fc214f7337d8f3e7be3f197aac12f Mon Sep 17 00:00:00 2001 From: KMalkowski Date: Fri, 6 Oct 2023 13:29:03 +0200 Subject: [PATCH 1/3] added graphcommerce packages in node_modules to next-config watch options --- .../next-config/src/withGraphCommerce.ts | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packagesDev/next-config/src/withGraphCommerce.ts b/packagesDev/next-config/src/withGraphCommerce.ts index 9f39f17228..438f4f4ce8 100644 --- a/packagesDev/next-config/src/withGraphCommerce.ts +++ b/packagesDev/next-config/src/withGraphCommerce.ts @@ -13,18 +13,21 @@ let graphcommerceConfig: GraphCommerceConfig function domains(config: GraphCommerceConfig): DomainLocale[] { return Object.values( - config.storefront.reduce((acc, loc) => { - if (!loc.domain) return acc - - acc[loc.domain] = { - defaultLocale: loc.locale, - locales: [...(acc[loc.domain]?.locales ?? []), loc.locale], - domain: loc.domain, - http: process.env.NODE_ENV === 'development' || undefined, - } as DomainLocale - - return acc - }, {} as Record), + config.storefront.reduce( + (acc, loc) => { + if (!loc.domain) return acc + + acc[loc.domain] = { + defaultLocale: loc.locale, + locales: [...(acc[loc.domain]?.locales ?? []), loc.locale], + domain: loc.domain, + http: process.env.NODE_ENV === 'development' || undefined, + } as DomainLocale + + return acc + }, + {} as Record, + ), ) } @@ -161,6 +164,11 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf ], } + config.watchOptions = { + ...(config.watchOptions ?? {}), + ignored: ['**/.git/**', `**/node_modules/!(@graphcommerce)**`, '**/.next/**'], + } + if (!config.resolve) config.resolve = {} config.resolve.alias = { ...config.resolve.alias, From 5f409e617afae36d5c6224f3c6eb8d085fc2e84c Mon Sep 17 00:00:00 2001 From: KMalkowski Date: Fri, 6 Oct 2023 13:50:58 +0200 Subject: [PATCH 2/3] added changeset --- .changeset/fresh-games-roll.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fresh-games-roll.md diff --git a/.changeset/fresh-games-roll.md b/.changeset/fresh-games-roll.md new file mode 100644 index 0000000000..1c7fa02ffa --- /dev/null +++ b/.changeset/fresh-games-roll.md @@ -0,0 +1,5 @@ +--- +'@graphcommerce/next-config': patch +--- + +Added @graphcommerce packages in node_modules to nextjs watch options From 88ccaf905dc7f6cf2378b1648faef64fe548a093 Mon Sep 17 00:00:00 2001 From: KMalkowski Date: Thu, 26 Oct 2023 14:13:24 +0200 Subject: [PATCH 3/3] modified original next regex with transpilePackages --- packagesDev/next-config/dist/withGraphCommerce.js | 4 ++++ packagesDev/next-config/src/withGraphCommerce.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packagesDev/next-config/dist/withGraphCommerce.js b/packagesDev/next-config/dist/withGraphCommerce.js index fc2ee146b8..4d69fb89b1 100644 --- a/packagesDev/next-config/dist/withGraphCommerce.js +++ b/packagesDev/next-config/dist/withGraphCommerce.js @@ -135,6 +135,10 @@ function withGraphCommerce(nextConfig, cwd) { new RegExp(`^(.+?[\\/]node_modules[\\/])(?!${transpilePackages.join('|')})`), ], }; + config.watchOptions = { + ...(config.watchOptions ?? {}), + ignored: new RegExp(`^((?:[^/]*(?:/|$))*)(.(git|next)|(node_modules[\\/](?!${transpilePackages.join('|')})))(/((?:[^/]*(?:/|$))*)(?:$|/))?`), + }; if (!config.resolve) config.resolve = {}; config.resolve.alias = { diff --git a/packagesDev/next-config/src/withGraphCommerce.ts b/packagesDev/next-config/src/withGraphCommerce.ts index 438f4f4ce8..596206509f 100644 --- a/packagesDev/next-config/src/withGraphCommerce.ts +++ b/packagesDev/next-config/src/withGraphCommerce.ts @@ -166,7 +166,11 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf config.watchOptions = { ...(config.watchOptions ?? {}), - ignored: ['**/.git/**', `**/node_modules/!(@graphcommerce)**`, '**/.next/**'], + ignored: new RegExp( + `^((?:[^/]*(?:/|$))*)(.(git|next)|(node_modules[\\/](?!${transpilePackages.join( + '|', + )})))(/((?:[^/]*(?:/|$))*)(?:$|/))?`, + ), } if (!config.resolve) config.resolve = {}