Skip to content

Commit d89f740

Browse files
authored
Write esbuild metafile to output dir (#2087)
* write esbuild metafile to output dir * add changeset
1 parent 41a3bde commit d89f740

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

.changeset/weak-parents-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Output esbuild metafile, can be inspected after `deploy --dry run`

packages/cli-v3/src/build/buildWorker.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ export async function buildWorker(options: BuildWorkerOptions) {
8686
? rewriteBuildManifestPaths(buildManifest, options.destination)
8787
: buildManifest;
8888

89-
await writeDeployFiles(buildManifest, resolvedConfig, options.destination);
89+
await writeDeployFiles({
90+
buildManifest,
91+
resolvedConfig,
92+
outputPath: options.destination,
93+
bundleResult,
94+
});
9095
}
9196

9297
return buildManifest;
@@ -140,11 +145,17 @@ function rewriteOutputPath(destinationDir: string, filePath: string) {
140145
}
141146
}
142147

143-
async function writeDeployFiles(
144-
buildManifest: BuildManifest,
145-
resolvedConfig: ResolvedConfig,
146-
outputPath: string
147-
) {
148+
async function writeDeployFiles({
149+
buildManifest,
150+
resolvedConfig,
151+
outputPath,
152+
bundleResult,
153+
}: {
154+
buildManifest: BuildManifest;
155+
resolvedConfig: ResolvedConfig;
156+
outputPath: string;
157+
bundleResult: BundleResult;
158+
}) {
148159
// Step 1. Read the package.json file
149160
const packageJson = await readProjectPackageJson(resolvedConfig.packageJsonPath);
150161

@@ -176,6 +187,7 @@ async function writeDeployFiles(
176187
});
177188

178189
await writeJSONFile(join(outputPath, "build.json"), buildManifestToJSON(buildManifest));
190+
await writeJSONFile(join(outputPath, "metafile.json"), bundleResult.metafile);
179191
await writeContainerfile(outputPath, buildManifest);
180192
}
181193

packages/cli-v3/src/build/bundle.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type BundleResult = {
4343
contentHash: string;
4444
files: TaskFile[];
4545
configPath: string;
46+
metafile: esbuild.Metafile;
4647
loaderEntryPoint: string | undefined;
4748
runWorkerEntryPoint: string | undefined;
4849
runControllerEntryPoint: string | undefined;
@@ -297,6 +298,7 @@ export async function getBundleResultFromBuild(
297298
indexControllerEntryPoint,
298299
initEntryPoint,
299300
contentHash: hasher.digest("hex"),
301+
metafile: result.metafile,
300302
};
301303
}
302304

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ export class BackgroundWorker {
4747
throw new Error("Worker already initialized");
4848
}
4949

50-
// Write the build manifest to this.build.outputPath/build.json
51-
await writeJSONFile(this.buildManifestPath, this.build, true);
52-
5350
logger.debug("indexing worker manifest", { build: this.build, params: this.params });
5451

5552
this.manifest = await indexWorkerManifest({

0 commit comments

Comments
 (0)