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

esbuild 0.16.0+ always replaces process.env.NODE_ENV #2718

Closed
sapphi-red opened this issue Dec 7, 2022 · 3 comments
Closed

esbuild 0.16.0+ always replaces process.env.NODE_ENV #2718

sapphi-red opened this issue Dec 7, 2022 · 3 comments

Comments

@sapphi-red
Copy link
Contributor

sapphi-red commented Dec 7, 2022

process.env.NODE_ENV = 'test'
const foo = process.env.NODE_ENV

is tranformed to

"development" = "test"; // invalid syntax here
const foo = "development";

from esbuild 0.16.0. (esbuild repl with 0.16.1)

This was not happening in esbuild 0.15.18.

Using --define:process.env.NODE_ENV=process.env.NODE_ENV (repl) seems to work.

@sapphi-red

This comment was marked as off-topic.

@evanw
Copy link
Owner

evanw commented Dec 7, 2022

Thanks for the report. This might be due to the transform API call now defaulting to the browser platform instead of the neutral platform. If I'm right, then setting platform: 'neutral' should be a quick way to get back to the old behavior. I'll look into this and #2719.

@sapphi-red
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants