Pesquisa de site

node.js - tsup --watch Reconstruindo/Reiniciando Quando server.listen é Usado em App Fastify no macOS 15.0.1


Estou desenvolvendo uma aplicação Fastify no macOS 15.0.1, e estou tendo problemas ao reconstruir e reiniciar o aplicativo sempre que incluo server.listen. Eu tentei usar tsup para assistir e reconstruir, mas assim que adiciono server.listen, o modo de observação para de detectar alterações nos arquivos.

Aqui está uma descrição da minha configuração:

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'