mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-24 08:01:38 +00:00
fix: codebase preview in standalone mode
- Fix standalone bundle path lookup in worker to not add redundant file extension (the path already contains .tar/.esm suffixes from the API) - Fix CLI preview tar bundle handling to preserve binary data correctly (was using btoa(blob.text()) which corrupted binary tar data) - Add integration tests for script/flow preview commands covering: - Regular scripts (non-codebase) - Codebase scripts (CJS and ESM formats) - Codebase scripts with assets (tar bundles) - Flow preview Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1125,7 +1125,7 @@ async function preview(
|
||||
const codebase =
|
||||
language == "bun" ? findCodebase(filePath, codebases) : undefined;
|
||||
|
||||
let bundledContent: string | undefined = undefined;
|
||||
let bundledContent: string | Blob | undefined = undefined;
|
||||
let isTar = false;
|
||||
|
||||
if (codebase) {
|
||||
@@ -1179,8 +1179,7 @@ async function preview(
|
||||
const fil = new File([file.contents as any], file.path.substring(1));
|
||||
tarball.append(fil);
|
||||
}
|
||||
const blob = await streamToBlob(tarball.stream());
|
||||
bundledContent = btoa(await blob.text());
|
||||
bundledContent = await streamToBlob(tarball.stream());
|
||||
isTar = true;
|
||||
} else if (Array.isArray(codebase.assets) && codebase.assets.length > 0) {
|
||||
// Handle assets
|
||||
@@ -1196,14 +1195,14 @@ async function preview(
|
||||
const file = new File([blob], asset.to);
|
||||
tarball.append(file);
|
||||
}
|
||||
const blob = await streamToBlob(tarball.stream());
|
||||
bundledContent = btoa(await blob.text());
|
||||
bundledContent = await streamToBlob(tarball.stream());
|
||||
isTar = true;
|
||||
}
|
||||
|
||||
if (!opts.silent) {
|
||||
const size = typeof bundledContent === "string" ? bundledContent.length : bundledContent.size;
|
||||
log.info(
|
||||
`Bundled ${filePath}: ${(bundledContent.length / 1024).toFixed(0)}kB (${(
|
||||
`Bundled ${filePath}: ${(size / 1024).toFixed(0)}kB (${(
|
||||
endTime - startTime
|
||||
).toFixed(0)}ms)`
|
||||
);
|
||||
@@ -1229,7 +1228,9 @@ async function preview(
|
||||
form.append("preview", JSON.stringify(previewPayload));
|
||||
form.append(
|
||||
"file",
|
||||
new Blob([bundledContent], { type: "application/javascript" })
|
||||
typeof bundledContent === "string"
|
||||
? new Blob([bundledContent], { type: "application/javascript" })
|
||||
: bundledContent
|
||||
);
|
||||
|
||||
const url =
|
||||
|
||||
Reference in New Issue
Block a user