-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
define process.env.NODE_ENV
works differently
#2719
Comments
I just looked into this. There isn't anything special about |
Oh, you are right. There aren't anything special with foo_bar = 'foo bar'
const bar = foo_bar is transformed to foo_bar = "foo bar";
const bar = "foo_bar"; |
I discovered that Webpack's DefinePlugin has the same behavior here (being able to replace an assignment target with a non-identifier). I can change esbuild to avoid generating code with a syntax error by avoiding replacements for assignment targets, but the result still won't make much sense since it means the load will be substituted but the store won't be. Edit: Maybe that means it's a good candidate for a warning. I should probably add one for this case ( |
I agree the result won't make sense. This is something I found while digging around #2718. |
is transformed to
with
--define:process.env.NODE_ENV=\"node_env\" --define:foo.bar=\"foo_bar\"
(repl).The generated code is not a valid code. A string cannot be a lvalue.
This happens with 0.11.23, 0.12.29, 0.13.15, 0.14.54, 0.15.18, 0.16.1.
The text was updated successfully, but these errors were encountered: