import type { BuildConfig } from "../types.ts"; import type { TransformConfig } from "../transform.ts"; import { BUILD_CONFIG } from "../build.ts"; import { TRANSFORM_CONFIG } from "../transform.ts"; import { deepMerge } from "@bundle/utils/deep-object"; /** * Creates the config needed for the transform, build, and context functions * @param type The type of config needed * @param opts The option(s) to use to create the config * @returns An object representing the configuration for that type of function */ export function createConfig(type: T, opts?: O): BuildConfig; export function createConfig(type: T, opts?: O): TransformConfig; export function createConfig(type: T, opts?: O): BuildConfig; export function createConfig(type: T, opts?: O) { if (type === "transform") { return deepMerge(structuredClone(TRANSFORM_CONFIG), opts as TransformConfig, { arrays: "replace" }); } else { return deepMerge(structuredClone(BUILD_CONFIG), opts as BuildConfig, { arrays: "replace" }); } }