Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): do not warn on NX_INVOKED_BY_RUNNER and only show warning once #19254

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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