From f7da875f0b4a357722a7079c8f1f1cec92259b38 Mon Sep 17 00:00:00 2001 From: Boshen Date: Mon, 29 Dec 2025 11:58:25 +0000 Subject: [PATCH] feat(oxlint)!: remove oxc_language_server binary (#17457) Given that all IDEs now use `--lsp`, we can "safely" remove the binary to reduce the published package size by half. This is breaking and forces people to upgrade their oxc IDE extensions. closes #12251 closes #15740 --- .github/workflows/release_apps.yml | 12 -- npm/oxfmt/scripts/generate-packages.js | 1 - npm/oxlint/bin/oxc_language_server | 151 ------------------------ npm/oxlint/package.json | 2 - npm/oxlint/scripts/generate-packages.js | 13 -- 5 files changed, 179 deletions(-) delete mode 100755 npm/oxlint/bin/oxc_language_server diff --git a/.github/workflows/release_apps.yml b/.github/workflows/release_apps.yml index 5778caa4d9bb5..4f1fb12cfa28e 100644 --- a/.github/workflows/release_apps.yml +++ b/.github/workflows/release_apps.yml @@ -119,9 +119,6 @@ jobs: - name: Build Rust binary run: cross build --release -p oxlint --features allocator --target=${{ matrix.target }} - - name: Build language server - run: cross build --release -p oxc_language_server --bin oxc_language_server --target=${{ matrix.target }} - # The binaries are zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss - name: Archive oxlint .node binary uses: ./.github/actions/archive-binary @@ -137,13 +134,6 @@ jobs: binary_name: oxlint-${{ matrix.code-target }}${{ runner.os == 'Windows' && '.exe' || '' }} archive_name: rust-oxlint-${{ matrix.code-target }} - - name: Archive language server binary - uses: ./.github/actions/archive-binary - with: - source_path: target/${{ matrix.target }}/release/oxc_language_server${{ runner.os == 'Windows' && '.exe' || '' }} - binary_name: oxc_language_server-${{ matrix.code-target }}${{ runner.os == 'Windows' && '.exe' || '' }} - archive_name: oxc_language_server-${{ matrix.code-target }} - - name: Upload Binary uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: @@ -152,8 +142,6 @@ jobs: path: | oxlint**.zip oxlint**.tar.gz - oxc_language_server**.zip - oxc_language_server**.tar.gz # For github release - name: Upload Binary diff --git a/npm/oxfmt/scripts/generate-packages.js b/npm/oxfmt/scripts/generate-packages.js index 2e04ca7f17b31..fc98d7df20ed2 100644 --- a/npm/oxfmt/scripts/generate-packages.js +++ b/npm/oxfmt/scripts/generate-packages.js @@ -92,7 +92,6 @@ function copyDistFiles() { } // NOTE: Must update npm/oxfmt/bin/oxfmt -// and npm/oxfmt/bin/oxc_language_server const TARGETS = [ "win32-x64", "win32-arm64", diff --git a/npm/oxlint/bin/oxc_language_server b/npm/oxlint/bin/oxc_language_server deleted file mode 100755 index 0eec37862fb3b..0000000000000 --- a/npm/oxlint/bin/oxc_language_server +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env node - -import { readFileSync } from "fs"; -import { spawnSync, execSync } from "child_process"; -import { createRequire } from "module"; - -const require = createRequire(import.meta.url); - -const isMusl = () => { - let musl = false; - if (process.platform === "linux") { - musl = isMuslFromFilesystem(); - if (musl === null) { - musl = isMuslFromReport(); - } - if (musl === null) { - musl = isMuslFromChildProcess(); - } - } - return musl; -}; - -const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-"); - -const isMuslFromFilesystem = () => { - try { - return readFileSync("/usr/bin/ldd", "utf-8").includes("musl"); - } catch { - return null; - } -}; - -const isMuslFromReport = () => { - const report = - typeof process.report.getReport === "function" - ? process.report.getReport() - : null; - if (!report) { - return null; - } - if (report.header && report.header.glibcVersionRuntime) { - return false; - } - if (Array.isArray(report.sharedObjects)) { - if (report.sharedObjects.some(isFileMusl)) { - return true; - } - } - return false; -}; - -const isMuslFromChildProcess = () => { - try { - return execSync("ldd --version", { encoding: "utf8" }) - .includes("musl"); - } catch (e) { - // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false - return false; - } -}; - -const { platform, arch, env, version, release } = process; - -const BIN_NAME = "oxc_language_server"; - -const PLATFORMS = { - win32: { - x64: { - musl: `@oxlint/win32-x64/${BIN_NAME}.exe`, - gnu: `@oxlint/win32-x64/${BIN_NAME}.exe`, - }, - arm64: { - musl: `@oxlint/win32-arm64/${BIN_NAME}.exe`, - gnu: `@oxlint/win32-arm64/${BIN_NAME}.exe`, - }, - }, - darwin: { - x64: { - musl: `@oxlint/darwin-x64/${BIN_NAME}`, - gnu: `@oxlint/darwin-x64/${BIN_NAME}`, - }, - arm64: { - musl: `@oxlint/darwin-arm64/${BIN_NAME}`, - gnu: `@oxlint/darwin-arm64/${BIN_NAME}`, - }, - }, - linux: { - x64: { - musl: `@oxlint/linux-x64-musl/${BIN_NAME}`, - gnu: `@oxlint/linux-x64-gnu/${BIN_NAME}`, - }, - arm64: { - musl: `@oxlint/linux-arm64-musl/${BIN_NAME}`, - gnu: `@oxlint/linux-arm64-gnu/${BIN_NAME}`, - }, - }, -}; - -let binPath = PLATFORMS[platform]?.[arch]?.[isMusl() ? "musl" : "gnu"]; - -if (binPath) { - const result = spawnSync( - require.resolve(binPath), - process.argv.slice(2), - { - shell: false, - stdio: "inherit", - env: { - ...env, - JS_RUNTIME_VERSION: version, - JS_RUNTIME_NAME: release.name, - NODE_PACKAGE_MANAGER: detectPackageManager(), - }, - } - ); - - if (result.error) { - throw result.error; - } - - process.exitCode = result.status; -} else { - let target = `${platform}-${arch}`; - if (isMusl()) { - target = `${target}-musl`; - } - console.error( - `The oxc_language_server CLI package doesn't ship with prebuilt binaries for your platform (${target}) yet. ` + - "You can create an issue at https://github.com/oxc-project/oxc/issues for support." - ); - process.exitCode = 1; -} - -/** - * NPM, Yarn, and other package manager set the `npm_config_user_agent`. It has the following format: - * - * ``` - * "npm/8.3.0 node/v16.13.2 win32 x64 workspaces/false - * ``` - * - * @returns The package manager string (`npm/8.3.0`) or null if the user agent string isn't set. - */ -function detectPackageManager() { - const userAgent = env.npm_config_user_agent; - - if (userAgent == null) { - return null; - } - - return userAgent.split(" ")[0]; -} diff --git a/npm/oxlint/package.json b/npm/oxlint/package.json index bbb97063c1068..009eb5c4ec464 100644 --- a/npm/oxlint/package.json +++ b/npm/oxlint/package.json @@ -16,14 +16,12 @@ "url": "https://github.com/sponsors/Boshen" }, "bin": { - "oxc_language_server": "bin/oxc_language_server", "oxlint": "bin/oxlint" }, "files": [ "configuration_schema.json", "dist", "README.md", - "bin/oxc_language_server", "bin/oxlint" ], "type": "module", diff --git a/npm/oxlint/scripts/generate-packages.js b/npm/oxlint/scripts/generate-packages.js index 8cac13b88d60c..f630382deb86c 100644 --- a/npm/oxlint/scripts/generate-packages.js +++ b/npm/oxlint/scripts/generate-packages.js @@ -7,7 +7,6 @@ import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; const OXLINT_BIN_NAME = "oxlint"; -const OXLS_BIN_NAME = "oxc_language_server"; /** /npm/oxlint` */ const OXLINT_ROOT = resolve(fileURLToPath(import.meta.url), "../.."); /** `/npm` */ @@ -60,9 +59,6 @@ function generateNativePackage(target) { os: [platform], cpu: [arch], ...libc, - publishConfig: { - executableFiles: ["oxc_language_server"], - }, }; const manifestPath = resolve(packageRoot, "package.json"); @@ -73,16 +69,8 @@ function generateNativePackage(target) { const oxlintBinSource = resolve(REPO_ROOT, `${OXLINT_BIN_NAME}.${target}.node`); const oxlintBinTarget = resolve(packageRoot, `${OXLINT_BIN_NAME}.${target}.node`); - const ext = platform === "win32" ? ".exe" : ""; - const oxlsBinSource = resolve(REPO_ROOT, `${OXLS_BIN_NAME}-${target}${ext}`); - const oxlsBinTarget = resolve(packageRoot, `${OXLS_BIN_NAME}${ext}`); - console.log(`Copy linter binary ${oxlintBinSource}`); fs.copyFileSync(oxlintBinSource, oxlintBinTarget); - - console.log(`Copy language server binary ${oxlsBinSource}`); - fs.copyFileSync(oxlsBinSource, oxlsBinTarget); - fs.chmodSync(oxlsBinTarget, 0o755); } function writeManifest() { @@ -121,7 +109,6 @@ function copyDistFiles() { fs.cpSync(OXLINT_DIST_SRC, OXLINT_DIST_DEST, { recursive: true }); } -// NOTE: Must update npm/oxlint/bin/oxc_language_server const TARGETS = [ "win32-x64", "win32-arm64",