question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change to `process?.env?.NODE_ENV`?

See original GitHub issue

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:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
agilgur5commented, Mar 22, 2020

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.

1reaction
taioncommented, Mar 21, 2020

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found