Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(dev): ignore extension build staging directories in the watcher (#5257)

Andrew Barbadff87bc0dea5
diff --git a/.changeset/dev-watch-ignore-extension-staging.md b/.changeset/dev-watch-ignore-extension-staging.md
new file mode 100644
index 000000000..22f61592d
--- /dev/null
+++ b/.changeset/dev-watch-ignore-extension-staging.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+`eve dev` now rebuilds once per edit to a source-backed workspace extension. Before, the temporary `.eve-extension-build-*` files from the extension build started a second, unnecessary rebuild.
diff --git a/packages/eve/src/internal/nitro/host/build-extension.ts b/packages/eve/src/internal/nitro/host/build-extension.ts
index a1410640e..57f808f16 100644
--- a/packages/eve/src/internal/nitro/host/build-extension.ts
+++ b/packages/eve/src/internal/nitro/host/build-extension.ts
@@ -25,6 +25,13 @@ import {
export { tryReadExtensionBuildConfig };
export type { ExtensionBuildConfig };
+/**
+ * Prefix of the per-build staging directory created inside the extension
+ * package. It must share a filesystem with the output directory so the final
+ * swap is a rename.
+ */
+export const EXTENSION_BUILD_STAGING_DIRECTORY_PREFIX = ".eve-extension-build-";
+
/**
* Builds a dist-only extension package. Authored modules are transformed as a
* path-preserving graph, declarations and assets are emitted beside them, and
@@ -62,7 +69,7 @@ export async function buildExtensionPackage(
);
}
- const transactionRoot = await mkdtemp(join(appRoot, ".eve-extension-build-"));
+ const transactionRoot = await mkdtemp(join(appRoot, EXTENSION_BUILD_STAGING_DIRECTORY_PREFIX));
const stagedOutDir = join(transactionRoot, "output");
const stagedDistRoot = join(stagedOutDir, relative(config.outDir, config.distRoot));
let preserveTransactionRoot = false;
diff --git a/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.scenario.test.ts b/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.scenario.test.ts
index 8d29360bf..09fd43a0f 100644
--- a/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.scenario.test.ts
+++ b/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.scenario.test.ts
@@ -298,7 +298,7 @@ describe("startAuthoredSourceWatcher", () => {
}
});
- it("watches workspace extension build inputs and ignores its managed output", async () => {
+ it("watches workspace extension build inputs and ignores its build output", async () => {
const appRoot = await mkdtemp(join(tmpdir(), "eve-dev-watch-extension-"));
const packageRoot = join(appRoot, "packages", "crm");
const sourceRoot = join(packageRoot, "extension");
@@ -339,6 +339,9 @@ describe("startAuthoredSourceWatcher", () => {
expect(paths).toContain(tsconfigPath);
const ignored = getIgnoredPredicate();
expect(ignored(join(outDir, "extension", "tools", "search.mjs"))).toBe(true);
+ expect(
+ ignored(join(packageRoot, ".eve-extension-build-a1B2c3", "barrels", "index.mjs")),
+ ).toBe(true);
expect(ignored(join(sourceRoot, "tools", "search.ts"))).toBe(false);
} finally {
await watcher.close();
diff --git a/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.ts b/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.ts
index 7541f9f2a..6bbf62a00 100644
--- a/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.ts
+++ b/packages/eve/src/internal/nitro/host/dev-authored-source-watcher.ts
@@ -4,6 +4,7 @@ import { watch } from "#compiled/chokidar/index.js";
import { toErrorMessage } from "#shared/errors.js";
import { resolveTsConfigDependencyPaths } from "#internal/application/tsconfig-dependencies.js";
import { resolveDevelopmentSourceSnapshotWatchPaths } from "#internal/nitro/dev-runtime-source-snapshot.js";
+import { EXTENSION_BUILD_STAGING_DIRECTORY_PREFIX } from "#internal/nitro/host/build-extension.js";
import type { PreparedDevelopmentApplicationHost } from "#internal/nitro/host/types.js";
import type { WorkspaceExtension } from "#internal/nitro/host/workspace-extensions.js";
import type { DevelopmentAuthoredRebuildCoordinator } from "#internal/nitro/host/dev-authored-rebuild-coordinator.js";
@@ -337,8 +338,11 @@ function shouldIgnoreWatcherPath(
const pathParts = normalizedPath.split(sep).filter(Boolean);
return (
- pathParts.some((part) => WATCHER_IGNORED_DIRECTORY_NAMES.has(part)) ||
- workspaceExtensions.some((extension) => isPathInsideOrEqual(path, extension.config.outDir))
+ pathParts.some(
+ (part) =>
+ WATCHER_IGNORED_DIRECTORY_NAMES.has(part) ||
+ part.startsWith(EXTENSION_BUILD_STAGING_DIRECTORY_PREFIX),
+ ) || workspaceExtensions.some((extension) => isPathInsideOrEqual(path, extension.config.outDir))
);
}