// src/lib/createBuildConfig.ts
import { readFileSync } from "node:fs";

// src/lib/defaultBuildConfig.ts
var defaultBuildConfig = {
  compilerOptions: {
    rootDir: "src",
    rootDirs: ["package.json"]
  },
  exclude: [
    "**/build",
    "**/dist",
    "**/node_modules",
    "**/*.spec.*",
    "**/*.spec",
    "**/*.stories.*",
    "**/*.example.*",
    "**/spec/*",
    "**/stories/*"
  ],
  include: ["src"]
};

// src/lib/createBuildConfig.ts
var getGeneralTypescriptConfig = (location) => {
  let generalConfig;
  try {
    generalConfig = readFileSync(`${location}/tsconfig.json`, { encoding: "utf8" });
  } catch {
    return false;
  }
  return JSON.parse(generalConfig);
};
var createBuildConfig = (location, module, target, outDirSuffix) => {
  const generalConfigObject = getGeneralTypescriptConfig(location);
  if (generalConfigObject === false) {
    return void 0;
  }
  return {
    ...generalConfigObject,
    compilerOptions: {
      ...defaultBuildConfig.compilerOptions,
      ...generalConfigObject.compilerOptions,
      module,
      outDir: `./${generalConfigObject.compilerOptions?.outDir ?? "dist"}/${outDirSuffix}`,
      target
    },
    exclude: [...generalConfigObject.exclude ?? [], ...defaultBuildConfig.exclude],
    include: [...generalConfigObject.include ?? [], ...defaultBuildConfig.include]
  };
};
export {
  createBuildConfig
};
//# sourceMappingURL=createBuildConfig.mjs.map
