import { BaseEngine } from "./BaseEngine.js";
import { createLazyLogger } from "../runtime/lazy-logger.js";
const logger = createLazyLogger("sd:cli:engine:server");
/**
 * esbuild 기반 서버 패키지용 빌드 엔진
 *
 * esbuild(JS 번들) + tsc(타입체크)를 하나의 Worker 스레드에서 결합하는
 * server-build.worker를 래핑한다.
 */
export class ServerEsbuildEngine extends BaseEngine {
    constructor(options) {
        super(options);
    }
    _getWorkerPath() {
        return import.meta.resolve("../workers/server-build.worker");
    }
    _getTarget() {
        return "server";
    }
    async _callBuild(output) {
        logger.debug(`[${this._pkg.name}] worker.build 호출`);
        const result = await this._worker.build({
            name: this._pkg.name,
            cwd: this._cwd,
            pkgDir: this._pkg.dir,
            output,
            env: this._pkg.config.env,
            configs: this._pkg.config.configs,
            externals: this._pkg.config.externals,
            pm2: this._pkg.config.pm2,
            packageManager: this._pkg.config.packageManager,
        });
        return this._normalizeResult(result);
    }
    async _callStartWatch(output) {
        logger.debug(`[${this._pkg.name}] worker.startWatch 호출`);
        await this._worker.startWatch({
            name: this._pkg.name,
            cwd: this._cwd,
            pkgDir: this._pkg.dir,
            output,
            env: this._pkg.config.env,
            configs: this._pkg.config.configs,
            externals: this._pkg.config.externals,
            replaceDeps: this._replaceDeps,
        });
    }
}
//# sourceMappingURL=ServerEsbuildEngine.js.map