Turns out the reason is that our global DEV variable was always set to false when preact-compat was bundled. The reason being that we checked if process is available:
const DEV = typeof process !== 'undefined' && process.env && process.env.NODE_ENV!=='production';
But bundlers typically don't shim the process object and instead replace all string occurrences of process.env.NODE_ENV with development for example. After the bundler has done its magic the code would now look like this:
const DEV = typeof process !== 'undefined' && process.env && 'development'!=='production';
Note that process is still undefined which is why DEV will always be false.
Found this while debugging why
prop-types
didn't work inpreact-cli
(see: https://github.com/developit/preact-cli/issues/627).Turns out the reason is that our global
DEV
variable was always set tofalse
whenpreact-compat
was bundled. The reason being that we checked ifprocess
is available:But bundlers typically don't shim the
process
object and instead replace all string occurrences ofprocess.env.NODE_ENV
withdevelopment
for example. After the bundler has done its magic the code would now look like this:Note that
process
is stillundefined
which is whyDEV
will always be false.