Skip to content

Commit

Permalink
fix(nextjs): do not warn on NX_INVOKED_BY_RUNNER and only show warnin…
Browse files Browse the repository at this point in the history
…g once
  • Loading branch information
jaysoo committed Sep 20, 2023
1 parent e11d538 commit 9181584
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/next/plugins/with-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -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(
', '
Expand Down

0 comments on commit 9181584

Please sign in to comment.