jeffbski / redux-logic

Redux middleware for organizing all your business logic. Intercept actions and perform async processing.
MIT License
1.81k stars 107 forks source link

`NODE_ENV` is always '' (empty string) in browser. #174

Open renatomcamilio opened 3 years ago

renatomcamilio commented 3 years ago

I ran into this issue where NODE_ENV is always !== "production", because when running in the browser window won't be undefined.

Check the code below: https://github.com/jeffbski/redux-logic/blob/1034a3ecff5dc12d3fb82ed3386a86a89d3adab5/src/createLogic.js#L24

So, later on in the same file we reference it to decide whether to log warnings (using warnTimeout), and even in production builds we are seeing these logs: https://github.com/jeffbski/redux-logic/blob/1034a3ecff5dc12d3fb82ed3386a86a89d3adab5/src/createLogic.js#L188-L193

I have a couple questions regarding the way we define NODE_ENV here:

  1. why do we check for typeof window === 'undefined'? Is this just meant for the build/babel step?
  2. I'm using CRA, can't overwrite NODE_ENV. Do you have a suggestion how to approach this?
jeffbski commented 3 years ago

@renatomcamilio Thanks for reaching out.

Regarding your questions:

  1. Yes, this was for the build step
  2. yes, I assume you are wanting to silence the warning logs.

When you create your logic, just set warnTimeout: 0 and this should silence all of those logs.