DEV Community

Cover image for process.env as feature flags
Sibelius Seraphini for Woovi

Posted on

10 1

process.env as feature flags

At Woovi we are always looking to optimize our processes. We want to improve the DX to increase the productivity of every software engineer. We want to make everything faster, consuming fewer memory and also providing the best usability.

Experimentation leads to innovation. However, experimentation can also break what is stable. To avoid breaking any core process of our software engineer team, we release new DX improvement behind feature flags that can be turned on using process.env.

Below is an example of our Jest config that enable the developer to decide which jest transformer to use. Esbuild and SWC are faster transformer than babel-jest, although it breaks a few of our tests.

const jestTransformer = () => {
  if (
    !process.env?.JEST_TRANSFORMER ||
    process.env.JEST_TRANSFORMER === 'babel-jest'
  ) {
    return {
      '^.+\\.(js|ts|tsx)?$': 'babel-jest',
    };
  }

  if (process.env.JEST_TRANSFORMER === 'esbuild-jest') {
    return {
      '^.+\\.(js|ts|tsx)?$': 'esbuild-jest',
    };
  }

  if (process.env.JEST_TRANSFORMER === 'swc-jest') {
    return {
      '^.+\\.(js|ts|tsx)?$': [
        '@swc/jest',
        {
          sourceMaps: true,
          jsc: {
            parser: {
              syntax: 'typescript',
              tsx: true,
            },
          },
        },
      ],
    };
  }
};
Enter fullscreen mode Exit fullscreen mode

What experimentation and DX improvement are you doing in your codebase?


If you care about DX and wanna work with us, we are hiring!

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (1)

Collapse
 
iagocavalcante profile image
Iago Angelim Costa Cavalcante

We abuse a lot of shell scripts to increase your time to set up for new devs and use a 1pass CLI to store our envs var, so we can set up almost everything running one command.

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay