Closed
Description
I have written an assert function which checks the "development mode" and then check the condtion and throws if the condtion is false. In the production mode, webpack removes the function body.
I would like to remove the call - assert(condition()) - scattered inside my code base in production. I am ok with an empty assert function call but the assert argument - condition() - can be an expensive function call. That's what i want to avoid.
- One way is to check process.env.development && assert(condition()) everywhere.
- Another way is that i can pass a predicate function to assert and let the assert evaluate it after the development mode check.
- Another way is to use some webpack loader to strip function calls. Not sure, how safe it is and I think it is not possible to do that without ejecting.
what is the correct way to do this?