node.js - tsup --watch Reconstrucción/Reinicio Cuando se usa server.listen en Aplicación Fastify en macOS 15.0.1
Estoy desarrollando una aplicación Fastify en macOS 15.0.1, y tengo problemas con reconstruir y reiniciar la aplicación cada vez que incluyo server.listen. He probado tsup para observar y reconstruir, pero tan pronto como agrego server.listen, el modo de observación deja de detectar los cambios en los archivos.
Aquí tienes un desglose de mi configuración:
import buildServer from './server';
async function main(): Promise<void> {
const server = await buildServer();
server.listen({ port: 4000, host: '0.0.0.0' });
}
void main();
servidor.ts
import type { FastifyInstance } from 'fastify';
import fastifyHelmet from '@fastify/helmet';
import Fastify from 'fastify';
import { serverOptions } from './configs';
const server = Fastify(serverOptions);
async function buildServer(): Promise<FastifyInstance> {
server.register(fastifyHelmet);
return server;
}
export default buildServer;
tsup
import { defineConfig } from 'tsup';
export default defineConfig(options => ({
entry: ['src/**/*.ts'],
clean: true,
format: ['cjs'],
...options,
}));
Comando para tsup:
tsup --watch --onSuccess 'node dist/index.js'