logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

loose-envify - replace Node.js environment variables with plain strings

Author

       Andres Suarez <zertosh@gmail.com>

Description

       Performs  a  Javascript  source-to-source transformation (transpiling), that efficiently replaces Node.js
       process.env environment variables with plain strings. This makes the environment variable  checks  faster
       and easier to optimize out.

Examples

       Running this source code:

         if (process.env.NODE_ENV === "development") {
           console.log('development only')
         }

       through loose-envify:

         loose-envify index.js > bundle.js

       with NODE_ENV set to production results in:

         if ("production" === "development") {
           console.log('development only')
         }

       which, when run through a minifier, would be stripped out completely.

       However, if you run the same script through loose-envify with NODE_ENV set to development it gives:

         if ("development" === "development") {
           console.log('development only')
         }

       The if statement will evaluate to true, so the code won't be removed.

Name

loose-envify - replace Node.js environment variables with plain strings

Synopsis

       loose-envify <javascript_source_file.js>

See Also