From dcb9243656cb56496266021fb5f45e00a54d1721 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 9 Dec 2024 13:44:36 -0800 Subject: [PATCH] watch for build completion --- extensions/vscode/scripts/esbuild.js | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/extensions/vscode/scripts/esbuild.js b/extensions/vscode/scripts/esbuild.js index 7e367bfaa..52d308d76 100644 --- a/extensions/vscode/scripts/esbuild.js +++ b/extensions/vscode/scripts/esbuild.js @@ -22,13 +22,25 @@ const esbuildConfig = { supported: { "dynamic-import": false }, }; +const ENDS_PATTERN = "VS Code Extension esbuild complete"; // used verbatim in vscode tasks to detect completion (async () => { - // Bundles the extension into one file - if (flags.includes("--watch")) { - const ctx = await esbuild.context(esbuildConfig); - await ctx.watch(); - } else { - await esbuild.build(esbuildConfig); - } - console.log("VS Code Extension esbuild complete"); // Used in task endpattern to signal completion -})(); \ No newline at end of file + // Bundles the extension into one file + if (flags.includes("--watch")) { + const ctx = await esbuild.context(esbuildConfig); + await ctx.watch({ + onRebuild(error, result) { + if (error) { + console.error("Watch build failed:", error); + throw error; + } else { + console.log(ENDS_PATTERN); + } + }, + }); + console.log("Esbuild: watching for changes..."); + } else { + await esbuild.build(esbuildConfig); + console.log(ENDS_PATTERN); + } + }, +)();