import { SERVER_FN_LOOKUP } from "../constants.js";
//#region src/start-compiler/load-module.ts
async function loadModuleForViteCompiler(opts) {
	if (opts.mode === "build") {
		const code = (await opts.loadModule({ id: opts.id })).code ?? "";
		opts.compiler.ingestModule({
			code,
			id: opts.id
		});
		return;
	}
	if (opts.mode !== "dev" || !opts.fetchModule) throw new Error(`could not load module ${opts.id}: unknown environment mode ${opts.mode}`);
	await opts.fetchModule(`${opts.id}?${SERVER_FN_LOOKUP}`);
}
//#endregion
export { loadModuleForViteCompiler };

//# sourceMappingURL=load-module.js.map