Change to `process?.env?.NODE_ENV`?
See original GitHub issueIssue Description
In order to make the ESM builds work on modern browsers, without additional bundlers involved, would you consider change the way process.env.NODE_ENV
is accessed to gracefully handle a missing process
?
process?.env?.NODE_ENV
or maybe process?.env.NODE_ENV
should be enough.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Working with Environment Variables in Node.js - Twilio
Environment variables are a great way to configure parts of your Node.js application. Learn how to work with them using helpful tools such ......
Read more >Setting Environment Variables for Node to retrieve
Environment variables (in this case) are being used to pass credentials to your application. USER_ID and USER_KEY can both be accessed from process.env....
Read more >Customizing Node.js .env files - LogRocket Blog
Learn how to configure a Node.js application via environment variables and customize an .env file with new environment variables.
Read more >How to set Environment Variable in node js? | Thirdock Techkno
Working with environment variables is a great way to configure different aspects of your Node.js application.
Read more >Using Environment Variables in Node.js for App Configuration ...
Learn why experienced Node.js developers use environment variables for app config and secrets, including how to manage default values and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yea I’ll agree with @taion that the browser ESM use-case should use a production minified bundle (like I mentioned in https://github.com/jaredpalmer/tsdx/issues/631#issuecomment-602131471), which would have
process.env.NODE_ENV
replaced and then DCE’d. The browser ESM use-case is quite different from the Node/bundler use-case.Well, hold on a sec. I feel like I’m missing something here.
If you look at e.g., the point of something like https://github.com/4Catalyzer/babel-plugin-dev-expression#invariant is to result in better production code after going through a minifier that does dead code elimination.
If you’re distributing code as-is, then it seems like you wouldn’t want this.
It seems a little odd to run code that has gone through this transform in the browser without an additional DCE step, but I’m probably just missing something?