vscode: Ensure extension.js is rebuilt when deleted
Right now, the vscode-extension:continue-ui:build task
deletes extension.js as part of its prepackage.js script.
This wouldn't normally be a problem, because extension.js
is generated by the vscode-extension:esbuild, and
vscode-extension:continue-ui:build is a dependency of
vscode-extension:esbuild, implying it should always get run
first.
But, vscode-extension:esbuild is a background task, that stays
running after it's been started once. Future calls to run that
task become no-ops, because it's already active. This means running
vscode-extension:esbuild ->
vscode-extension:continue-ui:build ->
vscode-extension:esbuild
will lead to the last vscode-extension:esbuild not regenerating
extension.js.
In order to resolve that problem, this commit adds a new foreground
task into the build pipeline:
vscode-extension:esbuild-notify
that tickles the watching background task to wake up and regenerate
extension.js
This commit is contained in:
parent
f08e501306
commit
9660c7ed08
3 changed files with 34 additions and 1 deletions
10
.vscode/tasks.json
vendored
10
.vscode/tasks.json
vendored
|
|
@ -28,6 +28,9 @@
|
|||
"vscode-extension:continue-ui:build",
|
||||
// // To bundle the code the same way we do for publishing
|
||||
"vscode-extension:esbuild",
|
||||
// To ensure extension.js is regenerated even if
|
||||
// vscode-extension:esbuild was already running in background
|
||||
"vscode-extension:esbuild-notify",
|
||||
// Start the React app that is used in the extension
|
||||
"gui:dev"
|
||||
],
|
||||
|
|
@ -36,6 +39,13 @@
|
|||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "vscode-extension:esbuild-notify",
|
||||
"dependsOn": ["vscode-extension:esbuild"],
|
||||
"type": "npm",
|
||||
"script": "esbuild-notify",
|
||||
"path": "extensions/vscode"
|
||||
},
|
||||
{
|
||||
"label": "vscode-extension:esbuild",
|
||||
"dependsOn": ["vscode-extension:continue-ui:build"],
|
||||
|
|
|
|||
|
|
@ -602,6 +602,7 @@
|
|||
"vscode:prepublish": "npm run esbuild-base -- --minify",
|
||||
"esbuild": "npm run esbuild-base -- --sourcemap",
|
||||
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch",
|
||||
"esbuild-notify": "npm run esbuild-base -- --sourcemap --notify",
|
||||
"esbuild:visualize": "esbuild-visualizer --metadata ./build/meta.json --filename ./build/stats.html --open",
|
||||
"tsc": "tsc -p ./",
|
||||
"tsc:check": "tsc -p ./ --noEmit",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const esbuild = require("esbuild");
|
||||
const fs = require("fs");
|
||||
|
||||
const flags = process.argv.slice(2);
|
||||
|
||||
|
|
@ -31,7 +32,6 @@ const esbuildConfig = {
|
|||
throw new Error(result.errors);
|
||||
} else {
|
||||
try {
|
||||
const fs = require("fs");
|
||||
fs.writeFileSync(
|
||||
"./build/meta.json",
|
||||
JSON.stringify(result.metafile, null, 2),
|
||||
|
|
@ -52,6 +52,28 @@ const esbuildConfig = {
|
|||
if (flags.includes("--watch")) {
|
||||
const ctx = await esbuild.context(esbuildConfig);
|
||||
await ctx.watch();
|
||||
} else if (flags.includes("--notify")) {
|
||||
const inFile = esbuildConfig.entryPoints[0];
|
||||
const outFile = esbuildConfig.outfile;
|
||||
|
||||
// The watcher automatically notices changes to source files
|
||||
// so the only thing it needs to be notified about is if the
|
||||
// output file gets removed.
|
||||
if (fs.existsSync (outFile)) {
|
||||
console.log("VS Code Extension esbuild up to date");
|
||||
return;
|
||||
}
|
||||
|
||||
fs.watchFile(outFile, (current, previous) => {
|
||||
if (current.size > 0) {
|
||||
console.log("VS Code Extension esbuild rebuild complete");
|
||||
fs.unwatchFile(outFile);
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Triggering VS Code Extension esbuild rebuild...");
|
||||
fs.utimesSync(inFile, new Date(), new Date());
|
||||
} else {
|
||||
await esbuild.build(esbuildConfig);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue