import path from "pathe";
import { exists } from "../../util/exists.js";
import { Vite } from "../vite/vite.js";
export async function TanStackStart(id, props) {
    const main = props?.wrangler?.main ??
        ((await exists(path.resolve(props?.cwd ?? process.cwd(), "src/server.ts")))
            ? "src/server.ts"
            : undefined);
    return await Vite(id, {
        entrypoint: "dist/server/index.js",
        assets: "dist/client",
        compatibility: "node",
        noBundle: true,
        spa: false,
        ...props,
        wrangler: {
            ...props?.wrangler,
            main,
            transform: async (spec) => {
                const transformed = (await props?.wrangler?.transform?.(spec)) ?? spec;
                if (!main) {
                    transformed.main = "@tanstack/react-start/server-entry";
                }
                return transformed;
            },
        },
    });
}
//# sourceMappingURL=tanstack-start.js.map