Skip to content

Commit 7ebe1d1

Browse files
authored
Merge pull request #8016 from joffeoja/remove_runtime_esbuild
build(vscode): remove bundled esbuild; require user-installed esbuild for config.ts
2 parents b8677b2 + b1bb2b1 commit 7ebe1d1

File tree

9 files changed

+53
-240
lines changed

9 files changed

+53
-240
lines changed

binary/utils/bundle-binary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { TARGET_TO_LANCEDB } = require("../utils/targets");
1111
const fs = require("fs");
1212
const {
1313
downloadSqlite,
14-
} = require("../../extensions/vscode/scripts/download-copy-sqlite-esbuild");
14+
} = require("../../extensions/vscode/scripts/download-copy-sqlite");
1515
const { fork } = require("child_process");
1616

1717
async function downloadNodeSqlite(target, targetDir) {

core/config/load.ts

Lines changed: 43 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
ModelRole,
1111
} from "@continuedev/config-yaml";
1212
import * as JSONC from "comment-json";
13-
import * as tar from "tar";
1413

1514
import {
1615
BrowserSerializedContinueConfig,
@@ -696,102 +695,43 @@ function escapeSpacesInPath(p: string): string {
696695
return p.replace(/ /g, "\\ ");
697696
}
698697

699-
async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) {
700-
// JetBrains is currently the only IDE that we've reached the plugin size limit and
701-
// therefore need to install esbuild manually to reduce the size
702-
if (ideType !== "jetbrains") {
703-
return;
704-
}
705-
706-
const globalContext = new GlobalContext();
707-
if (globalContext.get("hasDismissedConfigTsNoticeJetBrains")) {
708-
return;
709-
}
710-
711-
const esbuildPath = getEsbuildBinaryPath();
712-
713-
if (fs.existsSync(esbuildPath)) {
714-
return;
715-
}
716-
717-
console.debug("No esbuild binary detected");
718-
719-
const shouldInstall = await promptEsbuildInstallation(ide);
720-
721-
if (shouldInstall) {
722-
await downloadAndInstallEsbuild(ide);
723-
}
724-
}
725-
726-
async function promptEsbuildInstallation(ide: IDE): Promise<boolean> {
727-
const installMsg = "Install esbuild";
728-
const dismissMsg = "Dismiss";
729-
730-
const res = await ide.showToast(
731-
"warning",
732-
"You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?",
733-
dismissMsg,
734-
installMsg,
735-
);
736-
737-
if (res === dismissMsg) {
738-
const globalContext = new GlobalContext();
739-
globalContext.update("hasDismissedConfigTsNoticeJetBrains", true);
740-
return false;
741-
}
742-
743-
return res === installMsg;
744-
}
745-
746-
/**
747-
* The download logic is adapted from here: https://esbuild.github.io/getting-started/#download-a-build
748-
*/
749-
async function downloadAndInstallEsbuild(ide: IDE) {
750-
const esbuildPath = getEsbuildBinaryPath();
751-
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "esbuild-"));
698+
async function handleEsbuildInstallation(
699+
ide: IDE,
700+
_ideType: IdeType,
701+
): Promise<boolean> {
702+
// Only check when config.ts is going to be used; never auto-install.
703+
const installCmd = "npm i [email protected] --prefix ~/.continue";
752704

705+
// Try to detect a user-installed esbuild (normal resolution)
753706
try {
754-
const target = `${os.platform()}-${os.arch()}`;
755-
const version = "0.19.11";
756-
const url = `https://registry.npmjs.org/@esbuild/${target}/-/${target}-${version}.tgz`;
757-
const tgzPath = path.join(tempDir, `esbuild-${version}.tgz`);
758-
759-
console.debug(`Downloading esbuild from: ${url}`);
760-
execSync(`curl -fo "${tgzPath}" "${url}"`);
761-
762-
console.debug(`Extracting tgz file to: ${tempDir}`);
763-
await tar.x({
764-
file: tgzPath,
765-
cwd: tempDir,
766-
strip: 2, // Remove the top two levels of directories
767-
});
768-
769-
// Ensure the destination directory exists
770-
const destDir = path.dirname(esbuildPath);
771-
if (!fs.existsSync(destDir)) {
772-
fs.mkdirSync(destDir, { recursive: true });
773-
}
774-
775-
// Move the file
776-
const extractedBinaryPath = path.join(tempDir, "esbuild");
777-
fs.renameSync(extractedBinaryPath, esbuildPath);
778-
779-
// Ensure the binary is executable (not needed on Windows)
780-
if (os.platform() !== "win32") {
781-
fs.chmodSync(esbuildPath, 0o755);
707+
await import("esbuild");
708+
return true; // available
709+
} catch {
710+
// Try resolving from ~/.continue/node_modules as a courtesy
711+
try {
712+
const userEsbuild = path.join(
713+
os.homedir(),
714+
".continue",
715+
"node_modules",
716+
"esbuild",
717+
);
718+
const candidate = require.resolve("esbuild", { paths: [userEsbuild] });
719+
// eslint-disable-next-line @typescript-eslint/no-var-requires
720+
require(candidate);
721+
return true; // available via ~/.continue
722+
} catch {
723+
// Not available → show friendly instructions and opt out of building
724+
await ide.showToast(
725+
"error",
726+
[
727+
"config.ts has been deprecated and esbuild is no longer automatically installed by Continue.",
728+
"To use config.ts, install esbuild manually:",
729+
"",
730+
` ${installCmd}`,
731+
].join("\n"),
732+
);
733+
return false;
782734
}
783-
784-
// Clean up
785-
fs.unlinkSync(tgzPath);
786-
fs.rmSync(tempDir, { recursive: true });
787-
788-
await ide.showToast(
789-
"info",
790-
`'esbuild' successfully installed to ${esbuildPath}`,
791-
);
792-
} catch (error) {
793-
console.error("Error downloading or saving esbuild binary:", error);
794-
throw error;
795735
}
796736
}
797737

@@ -866,8 +806,15 @@ async function buildConfigTsandReadConfigJs(ide: IDE, ideType: IdeType) {
866806
return;
867807
}
868808

869-
await handleEsbuildInstallation(ide, ideType);
870-
await tryBuildConfigTs();
809+
// Only bother with esbuild if config.ts is actually customized
810+
if (currentContent.trim() !== DEFAULT_CONFIG_TS_CONTENTS.trim()) {
811+
const ok = await handleEsbuildInstallation(ide, ideType);
812+
if (!ok) {
813+
// esbuild not available → we already showed a friendly message; skip building
814+
return;
815+
}
816+
await tryBuildConfigTs();
817+
}
871818

872819
return readConfigJs();
873820
}

extensions/vscode/.vscodeignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ e2e
2424

2525
server/exe/**
2626
!out/node_modules/**
27-
!node_modules/@vscode/ripgrep/bin/rg
27+
!node_modules/@vscode/ripgrep/bin/rg
28+
29+
# Do not ship esbuild in VSIX
30+
out/node_modules/esbuild/**
31+
out/node_modules/@esbuild/**

extensions/vscode/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/vscode/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,6 @@
737737
"dbinfoz": "^0.14.0",
738738
"diff": "^7.0.0",
739739
"downshift": "^7.6.0",
740-
"esbuild": "0.17.19",
741740
"express": "^4.18.2",
742741
"fkill": "^8.1.0",
743742
"follow-redirects": "^1.15.4",

extensions/vscode/scripts/prepackage-cross-platform.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const {
2020
buildGui,
2121
copyOnnxRuntimeFromNodeModules,
2222
copyTreeSitterWasms,
23-
copyTreeSitterTagQryFiles,
2423
copyNodeModules,
25-
downloadEsbuildBinary,
2624
downloadRipgrepBinary,
2725
copySqliteBinary,
2826
installNodeModuleInTempDirAndCopyToCurrent,
@@ -90,9 +88,6 @@ async function package(target, os, arch, exe) {
9088
// Copy tree-sitter-wasm files
9189
await copyTreeSitterWasms();
9290

93-
// Copy tree-sitter tag query files
94-
await copyTreeSitterTagQryFiles();
95-
9691
// Install and copy over native modules
9792
// *** onnxruntime-node ***
9893
await copyOnnxRuntimeFromNodeModules(target);
@@ -116,12 +111,6 @@ async function package(target, os, arch, exe) {
116111
lancePackageToInstall,
117112
"@lancedb",
118113
);
119-
// *** esbuild ***
120-
// await installNodeModuleInTempDirAndCopyToCurrent(
121-
122-
// "@esbuild",
123-
// );
124-
await downloadEsbuildBinary(target);
125114

126115
// *** sqlite ***
127116
await downloadSqliteBinary(target);
@@ -187,19 +176,11 @@ async function package(target, os, arch, exe) {
187176

188177
// out/node_modules (to be accessed by extension.js)
189178
`out/node_modules/@vscode/ripgrep/bin/rg${exe}`,
190-
`out/node_modules/@esbuild/${
191-
target === "win32-arm64"
192-
? "esbuild.exe"
193-
: target === "win32-x64"
194-
? "win32-x64/esbuild.exe"
195-
: `${target}/bin/esbuild`
196-
}`,
197179
`out/node_modules/@lancedb/vectordb-${
198180
os === "win32"
199181
? "win32-x64-msvc"
200182
: `${target}${os === "linux" ? "-gnu" : ""}`
201183
}/index.node`,
202-
`out/node_modules/esbuild/lib/main.js`,
203184
]);
204185
}
205186

extensions/vscode/scripts/prepackage.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
autodetectPlatformAndArch,
1111
} = require("../../../scripts/util/index");
1212

13-
const { copySqlite, copyEsbuild } = require("./download-copy-sqlite-esbuild");
13+
const { copySqlite } = require("./download-copy-sqlite");
1414
const { generateAndCopyConfigYamlSchema } = require("./generate-copy-config");
1515
const { installAndCopyNodeModules } = require("./install-copy-nodemodule");
1616
const { npmInstall } = require("./npm-install");
@@ -303,14 +303,9 @@ void (async () => {
303303
);
304304

305305
await Promise.all([
306-
copyEsbuild(target),
307306
copySqlite(target),
308307
installAndCopyNodeModules(packageToInstall, "@lancedb"),
309308
]);
310-
} else {
311-
// Download esbuild from npm in tmp and copy over
312-
console.log("[info] npm installing esbuild binary");
313-
await installAndCopyNodeModules("[email protected]", "@esbuild");
314309
}
315310
}
316311

@@ -349,13 +344,7 @@ void (async () => {
349344
});
350345

351346
// Copy node_modules for pre-built binaries
352-
const NODE_MODULES_TO_COPY = [
353-
"esbuild",
354-
"@esbuild",
355-
"@lancedb",
356-
"@vscode/ripgrep",
357-
"workerpool",
358-
];
347+
const NODE_MODULES_TO_COPY = ["@lancedb", "@vscode/ripgrep", "workerpool"];
359348

360349
fs.mkdirSync("out/node_modules", { recursive: true });
361350

@@ -382,9 +371,6 @@ void (async () => {
382371
),
383372
);
384373

385-
// delete esbuild/bin because platform-specific @esbuild is downloaded
386-
fs.rmSync(`out/node_modules/esbuild/bin`, { recursive: true });
387-
388374
console.log(`[info] Copied ${NODE_MODULES_TO_COPY.join(", ")}`);
389375

390376
// Copy over any worker files
@@ -442,15 +428,7 @@ void (async () => {
442428

443429
// out/node_modules (to be accessed by extension.js)
444430
`out/node_modules/@vscode/ripgrep/bin/rg${exe}`,
445-
`out/node_modules/@esbuild/${
446-
target === "win32-arm64"
447-
? "esbuild.exe"
448-
: target === "win32-x64"
449-
? "win32-x64/esbuild.exe"
450-
: `${target}/bin/esbuild`
451-
}`,
452431
`out/node_modules/@lancedb/vectordb-${target}${isWinTarget ? "-msvc" : ""}${isLinuxTarget ? "-gnu" : ""}/index.node`,
453-
`out/node_modules/esbuild/lib/main.js`,
454432
]);
455433

456434
console.log(

0 commit comments

Comments
 (0)