From 9181584a9912d333cfd97954c524680873c80e01 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Wed, 20 Sep 2023 10:26:41 -0400 Subject: [PATCH] fix(nextjs): do not warn on NX_INVOKED_BY_RUNNER and only show warning once --- packages/next/plugins/with-nx.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index e445aac268a9a..16f9e8d73df44 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -18,6 +18,7 @@ const baseNXEnvironmentVariables = [ 'NX_PERF_LOGGING', 'NX_PROFILE', 'NX_PROJECT_GRAPH_CACHE_DIRECTORY', + 'NX_INVOKED_BY_RUNNER', // This is from nx cloud runner 'NX_PROJECT_GRAPH_MAX_WORKERS', 'NX_RUNNER', 'NX_SKIP_NX_CACHE', @@ -408,6 +409,9 @@ function getNxEnvironmentVariables() { return env; }, {}); } + +let hasWarnedAboutDeprecatedEnvVariables = false; + /** * TODO(v18) * @deprecated Use Next.js 9.4+ built-in support for environment variables. Reference https://nextjs.org/docs/pages/api-reference/next-config-js/env @@ -428,7 +432,8 @@ function addNxEnvVariables(config: any) { ); const vars = getNonBaseVariables(env); - if (vars.length > 0) { + if (vars.length > 0 && !hasWarnedAboutDeprecatedEnvVariables) { + hasWarnedAboutDeprecatedEnvVariables = true; console.warn( `Warning, in Nx 18 environment variables starting with NX_ will not be available in the browser, and currently will not work with @nx/next:server executor.\nPlease rename the following environment variables: ${vars.join( ', '