Rework SDK watcher (#17305)

This commit is contained in:
Charles Bochet
2026-01-21 16:18:54 +01:00
committed by GitHub
parent 54a9a1087b
commit 5ee6853d7e
20 changed files with 264 additions and 427 deletions
@@ -20,7 +20,7 @@ const buildFunctionEntries = (
const entries: Record<string, string> = {};
for (const fn of handlerPaths) {
const { relativePath } = computeFunctionOutputPath(fn.handlerPath);
const relativePath = computeFunctionOutputPath(fn.handlerPath);
const chunkName = relativePath.replace(/\.js$/, '');
entries[chunkName] = path.join(appPath, fn.handlerPath);
}
@@ -50,7 +50,7 @@ export class FunctionsWatcher implements RestartableWatcher {
}
shouldRestart(manifest: ApplicationManifest): boolean {
const newEntries = buildFunctionEntries(this.appPath, manifest.serverlessFunctions);
const newEntries = buildFunctionEntries(this.appPath, manifest.serverlessFunctions ?? []);
const currentKeys = Object.keys(this.entries).sort();
const newKeys = Object.keys(newEntries).sort();
@@ -96,7 +96,7 @@ export class FunctionsWatcher implements RestartableWatcher {
await this.innerWatcher?.close();
this.innerWatcher = null;
this.entries = buildFunctionEntries(this.appPath, manifest.serverlessFunctions);
this.entries = buildFunctionEntries(this.appPath, manifest.serverlessFunctions ?? []);
if (this.hasEntries()) {
console.log(chalk.blue(' 📦 Building functions...'));
@@ -144,7 +144,7 @@ export class FunctionsWatcher implements RestartableWatcher {
outDir: functionsOutputDir,
emptyOutDir: false,
watch: {
include: ['src/**/*.ts', 'src/**/*.json'],
include: ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.json'],
exclude: ['node_modules/**', '.twenty/**', 'dist/**'],
},
lib: {