There's no standardized, cross-platform, developer-friendly way to detect what environment you're running code in. The JS community has generally centered around reading process.env.NODE_ENV
, but this property feels out of place in browser code, and requires a lot of typing at every usage (it's too easy to get wrong or flip the condition backwards). Some people set up __DEV__
to transpile down to process.env.NODE_ENV !== 'production'
for a better developer experience.
A new property, hung on the global
object. This spec is to satisfy node, browser, and native.