Skip to content

Commit 5539a58

Browse files
committed
attach metafile to background worker
1 parent bbe4aa3 commit 5539a58

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

packages/cli-v3/src/dev/backgroundWorker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { indexWorkerManifest } from "../indexing/indexWorkerManifest.js";
55
import { prettyError } from "../utilities/cliOutput.js";
66
import { writeJSONFile } from "../utilities/fileSystem.js";
77
import { logger } from "../utilities/logger.js";
8+
import type { Metafile } from "esbuild";
89

910
export type BackgroundWorkerOptions = {
1011
env: Record<string, string>;
@@ -19,6 +20,7 @@ export class BackgroundWorker {
1920

2021
constructor(
2122
public build: BuildManifest,
23+
public metafile: Metafile,
2224
public params: BackgroundWorkerOptions
2325
) {}
2426

packages/cli-v3/src/dev/devSession.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ export async function startDevSession({
116116
try {
117117
logger.debug("Updated bundle", { bundle, buildManifest });
118118

119-
await runtime.initializeWorker(buildManifest, workerDir?.remove ?? (() => {}));
119+
await runtime.initializeWorker(
120+
buildManifest,
121+
bundle.metafile,
122+
workerDir?.remove ?? (() => {})
123+
);
120124
} catch (error) {
121125
if (error instanceof Error) {
122126
eventBus.emit("backgroundWorkerIndexingError", buildManifest, error);

packages/cli-v3/src/dev/devSupervisor.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { CliApiClient } from "../apiClient.js";
1212
import { DevCommandOptions } from "../commands/dev.js";
1313
import { eventBus } from "../utilities/eventBus.js";
1414
import { logger } from "../utilities/logger.js";
15-
import { sanitizeEnvVars } from "../utilities/sanitizeEnvVars.js";
1615
import { resolveSourceFiles } from "../utilities/sourceFiles.js";
1716
import { BackgroundWorker } from "./backgroundWorker.js";
1817
import { WorkerRuntime } from "./workerRuntime.js";
@@ -25,6 +24,7 @@ import {
2524
} from "@trigger.dev/core/v3/workers";
2625
import pLimit from "p-limit";
2726
import { resolveLocalEnvVars } from "../utilities/localEnvVars.js";
27+
import type { Metafile } from "esbuild";
2828

2929
export type WorkerRuntimeOptions = {
3030
name: string | undefined;
@@ -113,7 +113,11 @@ class DevSupervisor implements WorkerRuntime {
113113
}
114114
}
115115

116-
async initializeWorker(manifest: BuildManifest, stop: () => void): Promise<void> {
116+
async initializeWorker(
117+
manifest: BuildManifest,
118+
metafile: Metafile,
119+
stop: () => void
120+
): Promise<void> {
117121
if (this.lastManifest && this.lastManifest.contentHash === manifest.contentHash) {
118122
logger.debug("worker skipped", { lastManifestContentHash: this.lastManifest?.contentHash });
119123
eventBus.emit("workerSkipped");
@@ -123,7 +127,7 @@ class DevSupervisor implements WorkerRuntime {
123127

124128
const env = await this.#getEnvVars();
125129

126-
const backgroundWorker = new BackgroundWorker(manifest, {
130+
const backgroundWorker = new BackgroundWorker(manifest, metafile, {
127131
env,
128132
cwd: this.options.config.workingDir,
129133
stop,

packages/cli-v3/src/dev/workerRuntime.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { BuildManifest } from "@trigger.dev/core/v3";
22
import { ResolvedConfig } from "@trigger.dev/core/v3/build";
33
import { CliApiClient } from "../apiClient.js";
44
import { DevCommandOptions } from "../commands/dev.js";
5+
import type { Metafile } from "esbuild";
56

67
export interface WorkerRuntime {
78
shutdown(): Promise<void>;
8-
initializeWorker(manifest: BuildManifest, stop: () => void): Promise<void>;
9+
initializeWorker(manifest: BuildManifest, metafile: Metafile, stop: () => void): Promise<void>;
910
}
1011

1112
export type WorkerRuntimeOptions = {

0 commit comments

Comments
 (0)