Skip to content

Instantly share code, notes, and snippets.

@zefanjajobse
Created June 3, 2025 09:04
Show Gist options
  • Select an option

  • Save zefanjajobse/9d9e65f51fe0a069d1f58bc411738dcf to your computer and use it in GitHub Desktop.

Select an option

Save zefanjajobse/9d9e65f51fe0a069d1f58bc411738dcf to your computer and use it in GitHub Desktop.
Support older browsers for both the code as the used node_modules of a react-typescript project

.browserlistrc:

# Browsers that we support

# Configure how you require

# https://github.com/browserslist/browserslist

defaults
chrome >= 48
Firefox >= 52

babel.config.ct:

import type { TransformOptions } from "@babel/core";

const config: TransformOptions = {
  ignore: [
    /core-js/,
  ],
  sourceType: "unambiguous",
  presets: [
    [
      "@babel/preset-env",
      {
        "targets": {
          "browsers": [
            "defaults",
            "chrome >= 48",
            "Firefox >= 52", // old ESR
          ]
        },
        "corejs": { version: "3.42", proposals: true },
        "modules": false,
        "useBuiltIns": "usage",
      }
    ],
    "@babel/preset-typescript",
    [
      "@babel/preset-react",
      {
        "runtime": "automatic"
      }
    ]
  ]
}

module.exports = config;

webpack.json:

{
  // ...
  module: {
      rules: [
        {
          test: /\.[mc]?[jt]sx?$/i,
          loader: "babel-loader",
        },
        // ...
      ],
       // ...
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment