diff --git a/binary/utils/bundle-binary.js b/binary/utils/bundle-binary.js index f0cde0d25..16bfe01b2 100644 --- a/binary/utils/bundle-binary.js +++ b/binary/utils/bundle-binary.js @@ -11,7 +11,7 @@ const { TARGET_TO_LANCEDB } = require("../utils/targets"); const fs = require("fs"); const { downloadSqlite, -} = require("../../extensions/vscode/scripts/download-copy-sqlite-esbuild"); +} = require("../../extensions/vscode/scripts/download-copy-sqlite"); const { fork } = require("child_process"); async function downloadNodeSqlite(target, targetDir) { diff --git a/core/config/load.ts b/core/config/load.ts index 69b982405..35d12d421 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -10,7 +10,6 @@ import { ModelRole, } from "@continuedev/config-yaml"; import * as JSONC from "comment-json"; -import * as tar from "tar"; import { BrowserSerializedContinueConfig, @@ -696,102 +695,43 @@ function escapeSpacesInPath(p: string): string { return p.replace(/ /g, "\\ "); } -async function handleEsbuildInstallation(ide: IDE, ideType: IdeType) { - // JetBrains is currently the only IDE that we've reached the plugin size limit and - // therefore need to install esbuild manually to reduce the size - if (ideType !== "jetbrains") { - return; - } - - const globalContext = new GlobalContext(); - if (globalContext.get("hasDismissedConfigTsNoticeJetBrains")) { - return; - } - - const esbuildPath = getEsbuildBinaryPath(); - - if (fs.existsSync(esbuildPath)) { - return; - } - - console.debug("No esbuild binary detected"); - - const shouldInstall = await promptEsbuildInstallation(ide); - - if (shouldInstall) { - await downloadAndInstallEsbuild(ide); - } -} - -async function promptEsbuildInstallation(ide: IDE): Promise { - const installMsg = "Install esbuild"; - const dismissMsg = "Dismiss"; - - const res = await ide.showToast( - "warning", - "You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?", - dismissMsg, - installMsg, - ); - - if (res === dismissMsg) { - const globalContext = new GlobalContext(); - globalContext.update("hasDismissedConfigTsNoticeJetBrains", true); - return false; - } - - return res === installMsg; -} - -/** - * The download logic is adapted from here: https://esbuild.github.io/getting-started/#download-a-build - */ -async function downloadAndInstallEsbuild(ide: IDE) { - const esbuildPath = getEsbuildBinaryPath(); - const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "esbuild-")); +async function handleEsbuildInstallation( + ide: IDE, + _ideType: IdeType, +): Promise { + // Only check when config.ts is going to be used; never auto-install. + const installCmd = "npm i esbuild@x.x.x --prefix ~/.continue"; + // Try to detect a user-installed esbuild (normal resolution) try { - const target = `${os.platform()}-${os.arch()}`; - const version = "0.19.11"; - const url = `https://registry.npmjs.org/@esbuild/${target}/-/${target}-${version}.tgz`; - const tgzPath = path.join(tempDir, `esbuild-${version}.tgz`); - - console.debug(`Downloading esbuild from: ${url}`); - execSync(`curl -fo "${tgzPath}" "${url}"`); - - console.debug(`Extracting tgz file to: ${tempDir}`); - await tar.x({ - file: tgzPath, - cwd: tempDir, - strip: 2, // Remove the top two levels of directories - }); - - // Ensure the destination directory exists - const destDir = path.dirname(esbuildPath); - if (!fs.existsSync(destDir)) { - fs.mkdirSync(destDir, { recursive: true }); + await import("esbuild"); + return true; // available + } catch { + // Try resolving from ~/.continue/node_modules as a courtesy + try { + const userEsbuild = path.join( + os.homedir(), + ".continue", + "node_modules", + "esbuild", + ); + const candidate = require.resolve("esbuild", { paths: [userEsbuild] }); + // eslint-disable-next-line @typescript-eslint/no-var-requires + require(candidate); + return true; // available via ~/.continue + } catch { + // Not available → show friendly instructions and opt out of building + await ide.showToast( + "error", + [ + "config.ts has been deprecated and esbuild is no longer automatically installed by Continue.", + "To use config.ts, install esbuild manually:", + "", + ` ${installCmd}`, + ].join("\n"), + ); + return false; } - - // Move the file - const extractedBinaryPath = path.join(tempDir, "esbuild"); - fs.renameSync(extractedBinaryPath, esbuildPath); - - // Ensure the binary is executable (not needed on Windows) - if (os.platform() !== "win32") { - fs.chmodSync(esbuildPath, 0o755); - } - - // Clean up - fs.unlinkSync(tgzPath); - fs.rmSync(tempDir, { recursive: true }); - - await ide.showToast( - "info", - `'esbuild' successfully installed to ${esbuildPath}`, - ); - } catch (error) { - console.error("Error downloading or saving esbuild binary:", error); - throw error; } } @@ -866,8 +806,15 @@ async function buildConfigTsandReadConfigJs(ide: IDE, ideType: IdeType) { return; } - await handleEsbuildInstallation(ide, ideType); - await tryBuildConfigTs(); + // Only bother with esbuild if config.ts is actually customized + if (currentContent.trim() !== DEFAULT_CONFIG_TS_CONTENTS.trim()) { + const ok = await handleEsbuildInstallation(ide, ideType); + if (!ok) { + // esbuild not available → we already showed a friendly message; skip building + return; + } + await tryBuildConfigTs(); + } return readConfigJs(); } diff --git a/extensions/vscode/.vscodeignore b/extensions/vscode/.vscodeignore index f2179a2c5..bc6ad391e 100644 --- a/extensions/vscode/.vscodeignore +++ b/extensions/vscode/.vscodeignore @@ -24,4 +24,8 @@ e2e server/exe/** !out/node_modules/** -!node_modules/@vscode/ripgrep/bin/rg \ No newline at end of file +!node_modules/@vscode/ripgrep/bin/rg + +# Do not ship esbuild in VSIX +out/node_modules/esbuild/** +out/node_modules/@esbuild/** diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 33ca66b52..5ca2cc7be 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -20,7 +20,6 @@ "dbinfoz": "^0.14.0", "diff": "^7.0.0", "downshift": "^7.6.0", - "esbuild": "0.17.19", "express": "^4.18.2", "fkill": "^8.1.0", "follow-redirects": "^1.15.4", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 5cb857224..242eadca6 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -737,7 +737,6 @@ "dbinfoz": "^0.14.0", "diff": "^7.0.0", "downshift": "^7.6.0", - "esbuild": "0.17.19", "express": "^4.18.2", "fkill": "^8.1.0", "follow-redirects": "^1.15.4", diff --git a/extensions/vscode/scripts/download-copy-sqlite-esbuild.js b/extensions/vscode/scripts/download-copy-sqlite.js similarity index 100% rename from extensions/vscode/scripts/download-copy-sqlite-esbuild.js rename to extensions/vscode/scripts/download-copy-sqlite.js diff --git a/extensions/vscode/scripts/prepackage-cross-platform.js b/extensions/vscode/scripts/prepackage-cross-platform.js index 640a81380..5dab13b5a 100644 --- a/extensions/vscode/scripts/prepackage-cross-platform.js +++ b/extensions/vscode/scripts/prepackage-cross-platform.js @@ -20,9 +20,7 @@ const { buildGui, copyOnnxRuntimeFromNodeModules, copyTreeSitterWasms, - copyTreeSitterTagQryFiles, copyNodeModules, - downloadEsbuildBinary, downloadRipgrepBinary, copySqliteBinary, installNodeModuleInTempDirAndCopyToCurrent, @@ -90,9 +88,6 @@ async function package(target, os, arch, exe) { // Copy tree-sitter-wasm files await copyTreeSitterWasms(); - // Copy tree-sitter tag query files - await copyTreeSitterTagQryFiles(); - // Install and copy over native modules // *** onnxruntime-node *** await copyOnnxRuntimeFromNodeModules(target); @@ -116,12 +111,6 @@ async function package(target, os, arch, exe) { lancePackageToInstall, "@lancedb", ); - // *** esbuild *** - // await installNodeModuleInTempDirAndCopyToCurrent( - // "esbuild@0.17.19", - // "@esbuild", - // ); - await downloadEsbuildBinary(target); // *** sqlite *** await downloadSqliteBinary(target); @@ -187,19 +176,11 @@ async function package(target, os, arch, exe) { // out/node_modules (to be accessed by extension.js) `out/node_modules/@vscode/ripgrep/bin/rg${exe}`, - `out/node_modules/@esbuild/${ - target === "win32-arm64" - ? "esbuild.exe" - : target === "win32-x64" - ? "win32-x64/esbuild.exe" - : `${target}/bin/esbuild` - }`, `out/node_modules/@lancedb/vectordb-${ os === "win32" ? "win32-x64-msvc" : `${target}${os === "linux" ? "-gnu" : ""}` }/index.node`, - `out/node_modules/esbuild/lib/main.js`, ]); } diff --git a/extensions/vscode/scripts/prepackage.js b/extensions/vscode/scripts/prepackage.js index 29dbf2e8e..6085dc19c 100644 --- a/extensions/vscode/scripts/prepackage.js +++ b/extensions/vscode/scripts/prepackage.js @@ -10,7 +10,7 @@ const { autodetectPlatformAndArch, } = require("../../../scripts/util/index"); -const { copySqlite, copyEsbuild } = require("./download-copy-sqlite-esbuild"); +const { copySqlite } = require("./download-copy-sqlite"); const { generateAndCopyConfigYamlSchema } = require("./generate-copy-config"); const { installAndCopyNodeModules } = require("./install-copy-nodemodule"); const { npmInstall } = require("./npm-install"); @@ -303,14 +303,9 @@ void (async () => { ); await Promise.all([ - copyEsbuild(target), copySqlite(target), installAndCopyNodeModules(packageToInstall, "@lancedb"), ]); - } else { - // Download esbuild from npm in tmp and copy over - console.log("[info] npm installing esbuild binary"); - await installAndCopyNodeModules("esbuild@0.17.19", "@esbuild"); } } @@ -349,13 +344,7 @@ void (async () => { }); // Copy node_modules for pre-built binaries - const NODE_MODULES_TO_COPY = [ - "esbuild", - "@esbuild", - "@lancedb", - "@vscode/ripgrep", - "workerpool", - ]; + const NODE_MODULES_TO_COPY = ["@lancedb", "@vscode/ripgrep", "workerpool"]; fs.mkdirSync("out/node_modules", { recursive: true }); @@ -382,9 +371,6 @@ void (async () => { ), ); - // delete esbuild/bin because platform-specific @esbuild is downloaded - fs.rmSync(`out/node_modules/esbuild/bin`, { recursive: true }); - console.log(`[info] Copied ${NODE_MODULES_TO_COPY.join(", ")}`); // Copy over any worker files @@ -442,15 +428,7 @@ void (async () => { // out/node_modules (to be accessed by extension.js) `out/node_modules/@vscode/ripgrep/bin/rg${exe}`, - `out/node_modules/@esbuild/${ - target === "win32-arm64" - ? "esbuild.exe" - : target === "win32-x64" - ? "win32-x64/esbuild.exe" - : `${target}/bin/esbuild` - }`, `out/node_modules/@lancedb/vectordb-${target}${isWinTarget ? "-msvc" : ""}${isLinuxTarget ? "-gnu" : ""}/index.node`, - `out/node_modules/esbuild/lib/main.js`, ]); console.log( diff --git a/extensions/vscode/scripts/utils.js b/extensions/vscode/scripts/utils.js index cae982a97..b965d0f60 100644 --- a/extensions/vscode/scripts/utils.js +++ b/extensions/vscode/scripts/utils.js @@ -180,31 +180,11 @@ async function copyTreeSitterWasms() { console.log("[info] Copied tree-sitter wasms"); } -async function copyTreeSitterTagQryFiles() { - // ncp( - // path.join( - // __dirname, - // "../../../core/node_modules/llm-code-highlighter/dist/tag-qry", - // ), - // path.join(__dirname, "../out/tag-qry"), - // (error) => { - // if (error) - // console.warn("Error copying code-highlighter tag-qry files", error); - // }, - // ); -} - async function copyNodeModules() { // Copy node_modules for pre-built binaries process.chdir(path.join(continueDir, "extensions", "vscode")); - const NODE_MODULES_TO_COPY = [ - "esbuild", - "@esbuild", - "@lancedb", - "@vscode/ripgrep", - "workerpool", - ]; + const NODE_MODULES_TO_COPY = ["@lancedb", "@vscode/ripgrep", "workerpool"]; fs.mkdirSync("out/node_modules", { recursive: true }); await Promise.all( @@ -230,82 +210,9 @@ async function copyNodeModules() { ), ); - // delete esbuild/bin because platform-specific @esbuild is downloaded - fs.rmdirSync(`out/node_modules/esbuild/bin`, { recursive: true }); - console.log(`[info] Copied ${NODE_MODULES_TO_COPY.join(", ")}`); } -// async function downloadEsbuildBinary(isGhAction, isArm, target) { -// process.chdir(path.join(continueDir, "extensions", "vscode")); - -// if (isGhAction && isArm) { -// // Download and unzip esbuild -// console.log("[info] Downloading pre-built esbuild binary"); -// rimrafSync("node_modules/@esbuild"); -// fs.mkdirSync("node_modules/@esbuild", { recursive: true }); -// execCmdSync( -// `curl -o node_modules/@esbuild/esbuild.zip https://continue-server-binaries.s3.us-west-1.amazonaws.com/${target}/esbuild.zip`, -// ); -// execCmdSync(`cd node_modules/@esbuild && unzip esbuild.zip`); -// fs.unlinkSync("node_modules/@esbuild/esbuild.zip"); -// } else { -// // Download esbuild from npm in tmp and copy over -// console.log("npm installing esbuild binary"); -// await installNodeModuleInTempDirAndCopyToCurrent( -// "esbuild@0.17.19", -// "@esbuild", -// ); -// } -// } - -async function downloadEsbuildBinary(target) { - console.log("[info] Downloading pre-built esbuild binary"); - rimrafSync("out/node_modules/@esbuild"); - fs.mkdirSync(`out/node_modules/@esbuild/${target}/bin`, { recursive: true }); - fs.mkdirSync(`out/tmp`, { recursive: true }); - const downloadUrl = { - "darwin-arm64": - "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", - "linux-arm64": - "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", - "win32-arm64": - "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", - "linux-x64": - "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", - "darwin-x64": - "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", - "win32-x64": - "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", - }[target]; - execCmdSync(`curl -L -o out/tmp/esbuild.tgz ${downloadUrl}`); - execCmdSync("cd out/tmp && tar -xvzf esbuild.tgz"); - // Copy the installed package back to the current directory - let tmpPath = "out/tmp/package/bin"; - let outPath = `out/node_modules/@esbuild/${target}/bin`; - if (target.startsWith("win")) { - tmpPath = "out/tmp/package"; - outPath = `out/node_modules/@esbuild/${target}`; - } - - await new Promise((resolve, reject) => { - ncp( - path.join(tmpPath), - path.join(outPath), - { dereference: true }, - (error) => { - if (error) { - console.error(`[error] Error copying esbuild package`, error); - reject(error); - } else { - resolve(); - } - }, - ); - }); - rimrafSync("out/tmp"); -} - async function downloadSqliteBinary(target) { console.log("[info] Downloading pre-built sqlite3 binary"); rimrafSync("../../core/node_modules/sqlite3/build"); @@ -354,7 +261,7 @@ async function downloadRipgrepBinary(target) { console.log("[info] Downloading pre-built ripgrep binary"); rimrafSync("node_modules/@vscode/ripgrep/bin"); fs.mkdirSync("node_modules/@vscode/ripgrep/bin", { recursive: true }); - 4; + const downloadUrl = { "darwin-arm64": "https://github.com/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-aarch64-apple-darwin.tar.gz", @@ -475,9 +382,7 @@ module.exports = { buildGui, copyOnnxRuntimeFromNodeModules, copyTreeSitterWasms, - copyTreeSitterTagQryFiles, copyNodeModules, - downloadEsbuildBinary, copySqliteBinary, installNodeModuleInTempDirAndCopyToCurrent, downloadSqliteBinary,