Repository: babel/babel
File: scripts/generators/tsconfig.js (JavaScript)

Code before:
            return [["", "/src"]];
          }
          if (name === "@babel/compat-data") {
            // map ./plugins to ./data/plugins.json
            const subExport = _export.slice(1);
            const subExportPath = exportPath
              .replace("./", "/data/")
              .replace(/\.js$/, ".json");
            return [[subExport, subExportPath]];
          }
          // [{esm, default}, "./lib/index.js"]
          if (Array.isArray(exportPath)) {
            exportPath = exportPath[1];
          }
          if (typeof exportPath === "object") {
            exportPath = exportPath.default;
          }
          if (
            exportPath.startsWith("./lib") &&
            (exportPath.endsWith(".js") || exportPath.endsWith(".cjs"))
          ) {
            // remove the leading `.` and trailing `.js`
            const subExport = _export
              .slice(1)
              .replace(/\.js$/, "")
              .replace(/\.cjs$/, "");
            const subExportPath = exportPath
              .replace("./lib", "/src")
              .replace(/\.js$/, ".ts")
              .replace(/\.cjs$/, ".cts")
              .replace(/\/index\.ts$/, "")
              .replace(/\/index\.cts$/, "");
            return [[subExport, subExportPath]];
          }
          return [];
        }
      );
      const dependencies = new Set([
        ...Object.keys(packageJSON.dependencies ?? {}),
        ...(name === "@babel/standalone"
          ? Object.keys(packageJSON.devDependencies ?? {})
          : []),
        ...Object.keys(packageJSON.peerDependencies ?? {}),
      ]);
      if (name === "@babel/core") {
        // This dependency is only used in Babel 7, and does not affect
        // types. Remove it to avoid a cycle.
        dependencies.delete("@babel/helper-module-transforms");
      }
      dependencyAliases.forEach((alias, dep) => {
        if (dependencies.has(dep)) dependencies.add(alias);

Review comment (suggestion):
```suggestion
              .replace(/\.c?js$/, "");
```

Code after:
            return [["", "/src"]];
          }
          if (name === "@babel/compat-data") {
            // map ./plugins to ./data/plugins.json
            const subExport = _export.slice(1);
            const subExportPath = exportPath
              .replace("./", "/data/")
              .replace(/\.js$/, ".json");
            return [[subExport, subExportPath]];
          }
          // [{esm, default}, "./lib/index.js"]
          if (Array.isArray(exportPath)) {
            exportPath = exportPath[1];
          }
          if (typeof exportPath === "object") {
            exportPath = exportPath.default;
          }
          if (
            exportPath.startsWith("./lib") &&
            (exportPath.endsWith(".js") || exportPath.endsWith(".cjs"))
          ) {
            // remove the leading `.` and trailing `.js`
            const subExport = _export.slice(1).replace(/\.c?js$/, "");
            const subExportPath = exportPath
              .replace("./lib", "/src")
              .replace(/\.js$/, ".ts")
              .replace(/\.cjs$/, ".cts")
              .replace(/\/index\.c?ts$/, "");
            return [[subExport, subExportPath]];
          }
          return [];
        }
      );
      const dependencies = new Set([
        ...Object.keys(packageJSON.dependencies ?? {}),
        ...(name === "@babel/standalone"
          ? Object.keys(packageJSON.devDependencies ?? {})
          : []),
        ...Object.keys(packageJSON.peerDependencies ?? {}),
      ]);
      if (name === "@babel/core") {
        // This dependency is only used in Babel 7, and does not affect
        // types. Remove it to avoid a cycle.
        dependencies.delete("@babel/helper-module-transforms");
      }
      dependencyAliases.forEach((alias, dep) => {
        if (dependencies.has(dep)) dependencies.add(alias);
      });
      return [
        name,
        {