[A photograph of code on a computer screen, as follows:]
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = "production";
process.env.NODE_ENV = "production";
Node's environment package is notoriously badly designed. Not only do you have to always get envs by this arguably unnecessary process.env.MY_ENV syntax, but the thing it returns is not a copy by default either, so pretty much anyone anywhere can accidentaly set this variable in runtime and everything will be set on fire!
As a programer I would intuitivly expect process.env.BABEL_ENV = "production"; to throw exception, but alas...
Yeah this code might be fine if it’s in a webpack file which is only executed when building for production. You can set up different files for different modes.
21
u/mansdem Jan 10 '22
Ok so pls don't commit this
28
u/ProdObfuscationLover Jan 10 '22
What is that abysmal cursive font on those letter "s"
6
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 10 '22
Image Transcription: Code
[A photograph of code on a computer screen, as follows:]
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/babalaban Jan 14 '22
Node's environment package is notoriously badly designed. Not only do you have to always get envs by this arguably unnecessary
process.env.MY_ENVsyntax, but the thing it returns is not a copy by default either, so pretty much anyone anywhere can accidentaly set this variable in runtime and everything will be set on fire!As a programer I would intuitivly expect
process.env.BABEL_ENV = "production";to throw exception, but alas...1
u/thebritisharecome Jan 10 '22
Looks like the webpack config that comes with React
1
u/maebreeze Jun 07 '22
i have no clue why i just read that or wtf i just read
0
u/[deleted] Jan 10 '22
[deleted] — view deleted comment