// src/actions/package/compile/createProgramFromConfig.ts
import ts from "typescript";
function createProgramFromConfig(options) {
  const {
    basePath,
    compilerOptions,
    configFilePath,
    exclude,
    files,
    include
  } = options;
  const readResult = ts.readConfigFile(configFilePath, (fileName) => ts.sys.readFile(fileName));
  if (readResult.error) {
    throw new Error(ts.flattenDiagnosticMessageText(readResult.error.messageText, "\n"));
  }
  const config = readResult.config ?? {};
  config.compilerOptions = { ...config.compilerOptions, ...compilerOptions };
  if (include) config.include = include;
  if (files) config.files = files;
  if (exclude) config.exclude = exclude;
  const parsed = ts.parseJsonConfigFileContent(config, ts.sys, basePath, void 0, configFilePath);
  return ts.createProgram({
    configFileParsingDiagnostics: parsed.errors,
    options: parsed.options,
    projectReferences: parsed.projectReferences,
    rootNames: parsed.fileNames
  });
}
export {
  createProgramFromConfig
};
//# sourceMappingURL=createProgramFromConfig.mjs.map
