Skip to content

Commit e033b07

Browse files
thomasballingerConvex, Inc.
authored andcommitted
Don't (double) bundle/deploy component definitions in the convex dir (#42647)
GitOrigin-RevId: 4aad998a5d5a4b5921b9650786edf23c301f09c7
1 parent 2b20741 commit e033b07

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/bundler/index.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@ export const actionsDir = "actions";
2626
export function* walkDir(
2727
fs: Filesystem,
2828
dirPath: string,
29+
shouldSkipDir?: (dirPath: string) => boolean,
2930
depth?: number,
3031
): Generator<{ isDir: boolean; path: string; depth: number }, void, void> {
3132
depth = depth ?? 0;
3233
for (const dirEntry of fs.listDir(dirPath).sort(consistentPathSort)) {
3334
const childPath = path.join(dirPath, dirEntry.name);
3435
if (dirEntry.isDirectory()) {
36+
if (shouldSkipDir && shouldSkipDir(childPath)) {
37+
continue;
38+
}
3539
yield { isDir: true, path: childPath, depth };
36-
yield* walkDir(fs, childPath, depth + 1);
40+
yield* walkDir(fs, childPath, shouldSkipDir, depth + 1);
3741
} else if (dirEntry.isFile()) {
3842
yield { isDir: false, path: childPath, depth };
3943
}
@@ -357,7 +361,22 @@ export async function entryPoints(
357361
): Promise<string[]> {
358362
const entryPoints = [];
359363

360-
for (const { isDir, path: fpath, depth } of walkDir(ctx.fs, dir)) {
364+
// Don't deploy directories in convex/ that define components
365+
// as this leads to double-deploying.
366+
const looksLikeNestedComponent = (dirPath: string): boolean => {
367+
const config = path.join(dirPath, "convex.config.ts");
368+
const isComponentDefinition = ctx.fs.exists(config);
369+
if (isComponentDefinition) {
370+
logVerbose(chalk.yellow(`Skipping component directory ${dirPath}`));
371+
}
372+
return isComponentDefinition;
373+
};
374+
375+
for (const { isDir, path: fpath, depth } of walkDir(
376+
ctx.fs,
377+
dir,
378+
looksLikeNestedComponent,
379+
)) {
361380
if (isDir) {
362381
continue;
363382
}

0 commit comments

Comments
 (0)