From 103e248b70d1acc5e6ed683f2fac6a804c62453b Mon Sep 17 00:00:00 2001 From: Trang Doan Date: Thu, 8 Aug 2024 23:24:27 +1000 Subject: [PATCH 1/3] fix(nextjs): Fix order, and wrong number of input parameters call to createWebpackConfig() --- packages/next/plugins/with-nx.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index 791380d4e71b4..9f67200481d52 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -220,8 +220,9 @@ function withNx( _nextConfig.nx?.fileReplacements ? joinPathFragments(workspaceRoot, projectDirectory) : workspaceRoot, - _nextConfig.nx?.assets || options.assets, - _nextConfig.nx?.fileReplacements || options.fileReplacements + projectDirectory, + _nextConfig.nx?.fileReplacements || options.fileReplacements, + _nextConfig.nx?.assets || options.assets )(userWebpackConfig ? userWebpackConfig(a, b) : a, b); return nextConfig; From 988732a6b2d470d10bf144904c3cab43ae265b61 Mon Sep 17 00:00:00 2001 From: Nicholas Cunningham Date: Tue, 13 Aug 2024 15:24:35 -0600 Subject: [PATCH 2/3] fix(nextjs): Add typing for createWebpackConfig --- packages/next/plugins/with-nx.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index 9f67200481d52..f91ea71efb941 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -212,7 +212,12 @@ function withNx( const userWebpackConfig = nextConfig.webpack; - const { createWebpackConfig } = require('@nx/next/src/utils/config'); + const { createWebpackConfig } = require(require.resolve( + '@nx/next/src/utils/config', + { + paths: [workspaceRoot], + } + )) as typeof import('@nx/next/src/utils/config'); // If we have file replacements or assets, inside of the next config we pass the workspaceRoot as a join of the workspaceRoot and the projectDirectory // Because the file replacements and assets are relative to the projectRoot, not the workspaceRoot nextConfig.webpack = (a, b) => @@ -221,8 +226,8 @@ function withNx( ? joinPathFragments(workspaceRoot, projectDirectory) : workspaceRoot, projectDirectory, - _nextConfig.nx?.fileReplacements || options.fileReplacements, - _nextConfig.nx?.assets || options.assets + _nextConfig.nx?.assets || options.assets, + _nextConfig.nx?.fileReplacements || options.fileReplacements )(userWebpackConfig ? userWebpackConfig(a, b) : a, b); return nextConfig; From a736ea19b9fedcecf7590519d8469e4aaf81f74e Mon Sep 17 00:00:00 2001 From: Trang Doan Date: Wed, 14 Aug 2024 09:28:57 +1000 Subject: [PATCH 3/3] fix(nextjs): Fix wrong order of assets, and fileReplacements options --- packages/next/plugins/with-nx.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index f91ea71efb941..49f1dca9b0d2d 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -226,8 +226,8 @@ function withNx( ? joinPathFragments(workspaceRoot, projectDirectory) : workspaceRoot, projectDirectory, - _nextConfig.nx?.assets || options.assets, - _nextConfig.nx?.fileReplacements || options.fileReplacements + _nextConfig.nx?.fileReplacements || options.fileReplacements, + _nextConfig.nx?.assets || options.assets )(userWebpackConfig ? userWebpackConfig(a, b) : a, b); return nextConfig;