Repository: babel/babel
File: packages/babel-helper-compilation-targets/src/index.ts (TypeScript)

Code before:

  if (!browsers && shouldSearchForConfig) {
    // https://github.com/browserslist/browserslist/blob/8ae85caa905d130f4ca86f7a998a5b63abbbe582/node.js#L243
    browsers = process.env.BROWSERSLIST;
    if (!browsers) {
      const configFile =
        options.configFile ||
        process.env.BROWSERSLIST_CONFIG ||
        browserslist.findConfigFile(configPath);
      if (configFile != null) {
        onBrowserslistConfigFound?.(configFile);
        browsers = browserslist.loadConfig({
          config: configFile,
          env: options.browserslistEnv,
        });
      }
    }

    if (browsers == null) {
      // If no targets are passed, we use browserslist's defaults.
      browsers = ["defaults"];
    }
  }

  // `esmodules` as a target indicates the specific set of browsers supporting ES Modules.
  // These values offers defaults of the `browsers` field.
  if (esmodules && !browsers?.length) {
    browsers = Object.keys(ESM_SUPPORT)
      .map(
        (browser: keyof typeof ESM_SUPPORT) =>
          `${browser} >= ${ESM_SUPPORT[browser]}`,
      )
      .join(", ");
    // skip `esmodules` processing below since `browsers` is already set
    esmodules = false;
  }

  // If current value of `browsers` is undefined (`ignoreBrowserslistConfig` should be `false`)
  // or an empty array (without any user config, use default config),
  // we don't need to call `resolveTargets` to execute the related methods of `browserslist` library.
  if (browsers?.length) {
    const queryBrowsers = resolveTargetsCached(
      browsers,
      options.browserslistEnv,
    );

    if (esmodules) {
      for (const browser of Object.keys(queryBrowsers) as Target[]) {
        if (browser !== "deno" && browser !== "ie") {
          const esmSupportVersion =
            ESM_SUPPORT[browser === "opera_mobile" ? "op_mob" : browser];

Review comment (suggestion):
```suggestion
  // These values offer defaults of the `browsers` field.
```

Code after:

  if (!browsers && shouldSearchForConfig) {
    // https://github.com/browserslist/browserslist/blob/8ae85caa905d130f4ca86f7a998a5b63abbbe582/node.js#L243
    browsers = process.env.BROWSERSLIST;
    if (!browsers) {
      const configFile =
        options.configFile ||
        process.env.BROWSERSLIST_CONFIG ||
        browserslist.findConfigFile(configPath);
      if (configFile != null) {
        onBrowserslistConfigFound?.(configFile);
        browsers = browserslist.loadConfig({
          config: configFile,
          env: options.browserslistEnv,
        });
      }
    }

    if (browsers == null) {
      // If no targets are passed, we use browserslist's defaults.
      browsers = ["defaults"];
    }
  }

  // `esmodules` as a target indicates the specific set of browsers supporting ES Modules.
  // These values offer defaults of the `browsers` field.
  if (esmodules && !browsers?.length) {
    browsers = Object.keys(ESM_SUPPORT)
      .map(
        (browser: keyof typeof ESM_SUPPORT) =>
          `${browser} >= ${ESM_SUPPORT[browser]}`,
      )
      .join(", ");
    // skip `esmodules` processing below since `browsers` is already set
    esmodules = false;
  }

  // If current value of `browsers` is undefined (`ignoreBrowserslistConfig` should be `false`)
  // or an empty array (without any user config, use default config),
  // we don't need to call `resolveTargets` to execute the related methods of `browserslist` library.
  if (browsers?.length) {
    const queryBrowsers = resolveTargetsCached(
      browsers,
      options.browserslistEnv,
    );

    if (esmodules) {
      for (const browser of Object.keys(queryBrowsers) as Target[]) {
        if (browser !== "deno" && browser !== "ie") {
          const esmSupportVersion =
            ESM_SUPPORT[browser === "opera_mobile" ? "op_mob" : browser];