Skip to content

Commit 5caa789

Browse files
committed
improve message
1 parent 1935fe1 commit 5caa789

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

crates/next-core/src/util.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ pub fn free_var_references_with_vercel_system_env_warnings(
107107
.0
108108
.into_iter()
109109
.map(|(k, value)| {
110-
const LIST: [&str; 11] = [
110+
const LIST: [&str; 12] = [
111+
"NEXT_DEPLOYMENT_ID",
111112
"VERCEL_BRANCH_URL",
112113
"VERCEL_DEPLOYMENT_ID",
113114
"VERCEL_GIT_COMMIT_AUTHOR_LOGIN",
@@ -128,16 +129,27 @@ pub fn free_var_references_with_vercel_system_env_warnings(
128129
] = &&*k
129130
&& a == "process"
130131
&& b == "env"
131-
&& c.strip_prefix("NEXT_PUBLIC_")
132-
.is_some_and(|n| LIST.binary_search(&n).is_ok())
132+
&& let Some(env_var) = c.strip_prefix("NEXT_PUBLIC_")
133+
&& LIST.binary_search(&env_var).is_ok()
133134
{
134-
let message = format!(
135-
"The system environment variable {} is being inlined. This variable \
136-
changes on every deployment, causing slower deploy times and worse \
137-
browser client-side caching.",
138-
c
139-
)
140-
.into();
135+
let message = match &**c {
136+
"NEXT_PUBLIC_NEXT_DEPLOYMENT_ID" | "NEXT_PUBLIC_VERCEL_DEPLOYMENT_ID" => {
137+
rcstr!(
138+
"The deployment id is being inlined. Use \
139+
process.env.NEXT_DEPLOYMENT_ID instead to access the same value \
140+
without inlining, for faster deploy times and better browser \
141+
client-side caching."
142+
)
143+
}
144+
_ => format!(
145+
"A system environment variable is being inlined. This variable \
146+
changes on every deployment, causing slower deploy times and worse \
147+
browser client-side caching. For server-side code, replace with \
148+
process.env.{} and for browser code, try to remove it.",
149+
env_var,
150+
)
151+
.into(),
152+
};
141153
FreeVarReference::ReportUsage {
142154
message,
143155
severity: if should_error {

0 commit comments

Comments
 (0)