You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bun.build--define should not substitution a variable that is assigned to with a substitution that is not assignable #21210
a variable being "defined" with --define should not be substituted in an assignment expression
when it is on the left side ( leftSide = rightSide ), and the value is not assignable like a number, string ,etc
a warning should be raised.
"read" of the VAR1 will be substituted.
bun build ... --define "VAR1=3"
VAR1=3// VAR1 is being assigned to console.log(VAR1)// VAR1 is being read
will output
VAR1=3// excluded from substitution console.log(3)// substituted
We should also still be able to define an assignable expression to the left hand sign
if the value is assignable such as var name, member expression , etc .
bun build ... --define "VAR1=can.assign"
will output
can.assign=3// excluded from substitution console.log(can.assign)// substituted
esbuild detects this case and shows this warning, and skips that substitution for the assignment ( as expected )
related issue
#21205 []
The feature makes substitution explicit for reads only.
solving this particular case, and the case
that VAR1 may be replaced with another global. (causing the other global to get overridden)
Activity
linear commentedon Jul 19, 2025
ENG-19693 `bun.build` `--define` should not substitution a variable that is assigned to with a substitution that is not assignable