From dcb9243656cb56496266021fb5f45e00a54d1721 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 9 Dec 2024 13:44:36 -0800 Subject: [PATCH 1/2] 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); + } + }, +)(); From 91d54c5743539565a1a6f627952c5d614099ddc9 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 9 Dec 2024 13:52:34 -0800 Subject: [PATCH 2/2] build on end --- extensions/vscode/scripts/esbuild.js | 44 +++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/extensions/vscode/scripts/esbuild.js b/extensions/vscode/scripts/esbuild.js index 52d308d76..a84a0c80f 100644 --- a/extensions/vscode/scripts/esbuild.js +++ b/extensions/vscode/scripts/esbuild.js @@ -20,27 +20,29 @@ const esbuildConfig = { inject: ["./scripts/importMetaUrl.js"], define: { "import.meta.url": "importMetaUrl" }, supported: { "dynamic-import": false }, + plugins: [ + { + name: "on-end-plugin", + setup(build) { + build.onEnd((result) => { + if (result.errors.length > 0) { + console.error("Build failed with errors:", result.errors); + throw new Error(result.errors); + } else { + console.log("VS Code Extension esbuild complete"); // used verbatim in vscode tasks to detect completion + } + }); + }, + }, + ], }; -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({ - 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); - } - }, -)(); + // Bundles the extension into one file + if (flags.includes("--watch")) { + const ctx = await esbuild.context(esbuildConfig); + await ctx.watch(); + } else { + await esbuild.build(esbuildConfig); + } +})();