From 0d1d889c28d664e31e046d151cba18e6d42beed3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Mar 2026 17:17:36 +0200 Subject: [PATCH] Remove tsx dependency (#32967) * Remove tsx dependency * Iterate * Iterate * Iterate --- apps/desktop/.eslintrc.cjs | 2 ++ apps/desktop/hak/matrix-seshat/build.ts | 4 ++-- apps/desktop/hak/matrix-seshat/check.ts | 6 +++--- apps/desktop/hak/tsconfig.json | 3 ++- apps/desktop/package.json | 9 ++++----- apps/desktop/scripts/copy-res.ts | 2 +- apps/desktop/scripts/fetch-package.ts | 6 +++--- apps/desktop/scripts/generate-nightly-version.ts | 2 +- apps/desktop/scripts/get-version.ts | 4 ++-- apps/desktop/scripts/hak/build.ts | 4 ++-- apps/desktop/scripts/hak/check.ts | 4 ++-- apps/desktop/scripts/hak/clean.ts | 4 ++-- apps/desktop/scripts/hak/copy.ts | 4 ++-- apps/desktop/scripts/hak/dep.ts | 2 +- apps/desktop/scripts/hak/fetch.ts | 4 ++-- apps/desktop/scripts/hak/hakEnv.ts | 9 ++++----- apps/desktop/scripts/hak/index.ts | 12 ++++++------ apps/desktop/scripts/hak/link.ts | 4 ++-- apps/desktop/scripts/set-version.ts | 2 +- apps/desktop/scripts/tsconfig.json | 5 +++-- pnpm-lock.yaml | 4 +--- 21 files changed, 48 insertions(+), 48 deletions(-) diff --git a/apps/desktop/.eslintrc.cjs b/apps/desktop/.eslintrc.cjs index 51466a9e77..d8f162c2f0 100644 --- a/apps/desktop/.eslintrc.cjs +++ b/apps/desktop/.eslintrc.cjs @@ -46,6 +46,7 @@ module.exports = { // Things we do that break the ideal style "prefer-promise-reject-errors": "off", "quotes": "off", + "n/file-extension-in-import": "off", "@typescript-eslint/no-explicit-any": "off", // We're okay with assertion errors when we ask for them @@ -62,6 +63,7 @@ module.exports = { // Things we do that break the ideal style "prefer-promise-reject-errors": "off", "quotes": "off", + "n/file-extension-in-import": "off", "@typescript-eslint/no-explicit-any": "off", // We're okay with assertion errors when we ask for them diff --git a/apps/desktop/hak/matrix-seshat/build.ts b/apps/desktop/hak/matrix-seshat/build.ts index b4e46f1f9b..48ddccf33c 100644 --- a/apps/desktop/hak/matrix-seshat/build.ts +++ b/apps/desktop/hak/matrix-seshat/build.ts @@ -6,8 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import type HakEnv from "../../scripts/hak/hakEnv.js"; -import type { DependencyInfo } from "../../scripts/hak/dep.js"; +import type HakEnv from "../../scripts/hak/hakEnv.ts"; +import type { DependencyInfo } from "../../scripts/hak/dep.ts"; export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { const env = hakEnv.makeGypEnv(); diff --git a/apps/desktop/hak/matrix-seshat/check.ts b/apps/desktop/hak/matrix-seshat/check.ts index 8e292df851..a62a239c80 100644 --- a/apps/desktop/hak/matrix-seshat/check.ts +++ b/apps/desktop/hak/matrix-seshat/check.ts @@ -9,9 +9,9 @@ Please see LICENSE files in the repository root for full details. import childProcess from "node:child_process"; import fsProm from "node:fs/promises"; -import type HakEnv from "../../scripts/hak/hakEnv.js"; -import type { Tool } from "../../scripts/hak/hakEnv.js"; -import type { DependencyInfo } from "../../scripts/hak/dep.js"; +import type HakEnv from "../../scripts/hak/hakEnv.ts"; +import type { Tool } from "../../scripts/hak/hakEnv.ts"; +import type { DependencyInfo } from "../../scripts/hak/dep.ts"; export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { const tools: Tool[] = [ diff --git a/apps/desktop/hak/tsconfig.json b/apps/desktop/hak/tsconfig.json index d2a8215cb4..f547523e48 100644 --- a/apps/desktop/hak/tsconfig.json +++ b/apps/desktop/hak/tsconfig.json @@ -6,7 +6,8 @@ "sourceMap": false, "strict": true, "lib": ["es2022"], - "types": ["node"] + "types": ["node"], + "allowImportingTsExtensions": true }, "include": ["../scripts/@types/*.d.ts", "./**/*.ts"] } diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 6e2177e127..e43c10023e 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -18,7 +18,7 @@ "type": "module", "files": [], "engines": { - "node": ">=18.0.0" + "node": ">=22.18" }, "scripts": { "i18n": "matrix-gen-i18n && pnpm i18n:sort && pnpm i18n:lint", @@ -26,7 +26,7 @@ "i18n:lint": "prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null", "i18n:diff": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && pnpm i18n && matrix-compare-i18n-files src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json", "mkdirs": "mkdirp packages deploys", - "fetch": "pnpm run mkdirs && tsx scripts/fetch-package.ts", + "fetch": "pnpm run mkdirs && node scripts/fetch-package.ts", "asar-webapp": "asar p webapp webapp.asar", "start": "pnpm run build:ts && pnpm run build:res && electron .", "lint": "pnpm lint:types && pnpm lint:js", @@ -44,13 +44,13 @@ "build:universal": "pnpm run build:ts && pnpm run build:res && electron-builder --universal", "build": "pnpm run build:ts && pnpm run build:res && electron-builder", "build:ts": "tsc", - "build:res": "tsx scripts/copy-res.ts", + "build:res": "node scripts/copy-res.ts", "docker:setup": "docker build --platform linux/amd64 -t element-desktop-dockerbuild -f dockerbuild/Dockerfile .", "docker:build:native": "scripts/in-docker.sh pnpm run hak", "docker:build": "scripts/in-docker.sh pnpm run build", "docker:install": "scripts/in-docker.sh pnpm install", "clean": "rimraf webapp.asar dist packages deploys lib", - "hak": "tsx scripts/hak/index.ts", + "hak": "node scripts/hak/index.ts", "test": "playwright test", "test:open": "pnpm test --ui", "test:screenshots:build": "docker build playwright -t element-desktop-playwright --platform linux/amd64", @@ -102,7 +102,6 @@ "prettier": "^3.0.0", "rimraf": "^6.0.0", "tar": "^7.5.8", - "tsx": "^4.19.2", "typescript": "5.9.3" }, "hakDependencies": { diff --git a/apps/desktop/scripts/copy-res.ts b/apps/desktop/scripts/copy-res.ts index fd5aa60f7c..18ce877d11 100755 --- a/apps/desktop/scripts/copy-res.ts +++ b/apps/desktop/scripts/copy-res.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S npx tsx +#!/usr/bin/env node // copies resources into the lib directory. diff --git a/apps/desktop/scripts/fetch-package.ts b/apps/desktop/scripts/fetch-package.ts index 728294545b..21876c2a69 100644 --- a/apps/desktop/scripts/fetch-package.ts +++ b/apps/desktop/scripts/fetch-package.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S npx tsx --resolveJsonModule +#!/usr/bin/env node import * as path from "node:path"; import { createWriteStream, promises as fs } from "node:fs"; @@ -7,8 +7,8 @@ import * as tar from "tar"; import * as asar from "@electron/asar"; import { promises as stream } from "node:stream"; -import riotDesktopPackageJson from "../package.json"; -import { setPackageVersion } from "./set-version.js"; +import riotDesktopPackageJson from "../package.json" with { type: "json" }; +import { setPackageVersion } from "./set-version.ts"; const PUB_KEY_URL = "https://packages.riot.im/element-release-key.asc"; const PACKAGE_URL_PREFIX = "https://github.com/element-hq/element-web/releases/download/"; diff --git a/apps/desktop/scripts/generate-nightly-version.ts b/apps/desktop/scripts/generate-nightly-version.ts index 90471746cb..eef0ab997b 100755 --- a/apps/desktop/scripts/generate-nightly-version.ts +++ b/apps/desktop/scripts/generate-nightly-version.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S npx tsx +#!/usr/bin/env node /** * Script to generate incremental Nightly build versions, based on the latest Nightly build version of that kind. diff --git a/apps/desktop/scripts/get-version.ts b/apps/desktop/scripts/get-version.ts index 74cee84a07..2d28b3a24d 100755 --- a/apps/desktop/scripts/get-version.ts +++ b/apps/desktop/scripts/get-version.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S npx tsx +#!/usr/bin/env node /* * Checks for the presence of a webapp, inspects its version and prints it @@ -6,7 +6,7 @@ import url from "node:url"; -import { versionFromAsar } from "./set-version.js"; +import { versionFromAsar } from "./set-version.ts"; async function main(): Promise { const version = await versionFromAsar(); diff --git a/apps/desktop/scripts/hak/build.ts b/apps/desktop/scripts/hak/build.ts index ccc680f694..2b2ab42ac5 100644 --- a/apps/desktop/scripts/hak/build.ts +++ b/apps/desktop/scripts/hak/build.ts @@ -6,8 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import type { DependencyInfo } from "./dep.js"; -import type HakEnv from "./hakEnv.js"; +import type { DependencyInfo } from "./dep.ts"; +import type HakEnv from "./hakEnv.ts"; export default async function build(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { await moduleInfo.scripts.build(hakEnv, moduleInfo); diff --git a/apps/desktop/scripts/hak/check.ts b/apps/desktop/scripts/hak/check.ts index 2a7ce6e497..dc55400fca 100644 --- a/apps/desktop/scripts/hak/check.ts +++ b/apps/desktop/scripts/hak/check.ts @@ -6,8 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import type { DependencyInfo } from "./dep.js"; -import type HakEnv from "./hakEnv.js"; +import type { DependencyInfo } from "./dep.ts"; +import type HakEnv from "./hakEnv.ts"; export default async function check(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { await moduleInfo.scripts.check?.(hakEnv, moduleInfo); diff --git a/apps/desktop/scripts/hak/clean.ts b/apps/desktop/scripts/hak/clean.ts index 30d545e188..2eb51fa45d 100644 --- a/apps/desktop/scripts/hak/clean.ts +++ b/apps/desktop/scripts/hak/clean.ts @@ -9,8 +9,8 @@ Please see LICENSE files in the repository root for full details. import path from "node:path"; import { rimraf } from "rimraf"; -import type { DependencyInfo } from "./dep.js"; -import type HakEnv from "./hakEnv.js"; +import type { DependencyInfo } from "./dep.ts"; +import type HakEnv from "./hakEnv.ts"; export default async function clean(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { await rimraf(moduleInfo.moduleDotHakDir); diff --git a/apps/desktop/scripts/hak/copy.ts b/apps/desktop/scripts/hak/copy.ts index 607792e622..dd266201cf 100644 --- a/apps/desktop/scripts/hak/copy.ts +++ b/apps/desktop/scripts/hak/copy.ts @@ -12,8 +12,8 @@ import childProcess from "node:child_process"; import { glob } from "glob"; import { mkdirp } from "mkdirp"; -import type HakEnv from "./hakEnv.js"; -import type { DependencyInfo } from "./dep.js"; +import type HakEnv from "./hakEnv.ts"; +import type { DependencyInfo } from "./dep.ts"; export default async function copy(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { if (moduleInfo.cfg.copy) { diff --git a/apps/desktop/scripts/hak/dep.ts b/apps/desktop/scripts/hak/dep.ts index bbb717e1cc..1d991c4a43 100644 --- a/apps/desktop/scripts/hak/dep.ts +++ b/apps/desktop/scripts/hak/dep.ts @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import type HakEnv from "./hakEnv.js"; +import type HakEnv from "./hakEnv.ts"; export interface DependencyInfo { name: string; diff --git a/apps/desktop/scripts/hak/fetch.ts b/apps/desktop/scripts/hak/fetch.ts index 79263639f7..c5e2e4deab 100644 --- a/apps/desktop/scripts/hak/fetch.ts +++ b/apps/desktop/scripts/hak/fetch.ts @@ -10,8 +10,8 @@ import fsProm from "node:fs/promises"; import pacote from "pacote"; import path from "node:path"; -import type HakEnv from "./hakEnv.js"; -import type { DependencyInfo } from "./dep.js"; +import type HakEnv from "./hakEnv.ts"; +import type { DependencyInfo } from "./dep.ts"; export default async function fetch(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { let haveModuleBuildDir; diff --git a/apps/desktop/scripts/hak/hakEnv.ts b/apps/desktop/scripts/hak/hakEnv.ts index 6872a8860e..edab24419b 100644 --- a/apps/desktop/scripts/hak/hakEnv.ts +++ b/apps/desktop/scripts/hak/hakEnv.ts @@ -11,7 +11,7 @@ import os from "node:os"; import { getElectronVersionFromInstalled } from "app-builder-lib/out/electron/electronVersion.js"; import childProcess, { type SpawnOptions } from "node:child_process"; -import { type Arch, type Target, TARGETS, getHost, isHostId, type TargetId } from "./target.js"; +import { type Arch, type Target, TARGETS, getHost, isHostId, type TargetId } from "./target.ts"; async function getRuntimeVersion(projectRoot: string): Promise { const electronVersion = await getElectronVersionFromInstalled(path.join(projectRoot, "..", "..")); @@ -28,11 +28,10 @@ export default class HakEnv { public runtime: string = "electron"; public runtimeVersion?: string; public dotHakDir: string; + public readonly projectRoot: string; - public constructor( - public readonly projectRoot: string, - targetId: TargetId | null, - ) { + public constructor(projectRoot: string, targetId: TargetId | null) { + this.projectRoot = projectRoot; const target = targetId ? TARGETS[targetId] : getHost(); if (!target) { diff --git a/apps/desktop/scripts/hak/index.ts b/apps/desktop/scripts/hak/index.ts index b78d64742b..ea02582632 100644 --- a/apps/desktop/scripts/hak/index.ts +++ b/apps/desktop/scripts/hak/index.ts @@ -9,11 +9,11 @@ Please see LICENSE files in the repository root for full details. import path, { dirname } from "node:path"; import { fileURLToPath } from "node:url"; -import HakEnv from "./hakEnv.js"; -import type { TargetId } from "./target.js"; -import type { DependencyInfo } from "./dep.js"; -import { loadJsonFile } from "../../src/utils.js"; -import packageJson from "../../package.json"; +import HakEnv from "./hakEnv.ts"; +import type { TargetId } from "./target.ts"; +import type { DependencyInfo } from "./dep.ts"; +import { loadJsonFile } from "../../src/utils.ts"; +import packageJson from "../../package.json" with { type: "json" }; // These can only be run on specific modules const MODULECOMMANDS = ["check", "fetch", "link", "build", "copy", "clean"]; @@ -127,7 +127,7 @@ async function main(): Promise { process.exit(1); } - const cmdFunc = (await import("./" + cmd)).default; + const cmdFunc = (await import(`./${cmd}.ts`)).default; for (const mod of modules) { const depInfo = deps[mod]; diff --git a/apps/desktop/scripts/hak/link.ts b/apps/desktop/scripts/hak/link.ts index 39009b90d3..81183a3584 100644 --- a/apps/desktop/scripts/hak/link.ts +++ b/apps/desktop/scripts/hak/link.ts @@ -6,8 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import type HakEnv from "./hakEnv.js"; -import { type DependencyInfo } from "./dep.js"; +import type HakEnv from "./hakEnv.ts"; +import { type DependencyInfo } from "./dep.ts"; export default async function link(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { await hakEnv.spawn("pnpm", ["link", moduleInfo.moduleOutDir], { diff --git a/apps/desktop/scripts/set-version.ts b/apps/desktop/scripts/set-version.ts index 37d005fc21..01e5027802 100755 --- a/apps/desktop/scripts/set-version.ts +++ b/apps/desktop/scripts/set-version.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env -S npx tsx +#!/usr/bin/env node /* * Checks for the presence of a webapp, inspects its version and sets the diff --git a/apps/desktop/scripts/tsconfig.json b/apps/desktop/scripts/tsconfig.json index 95ab5db331..bff3b8ae81 100644 --- a/apps/desktop/scripts/tsconfig.json +++ b/apps/desktop/scripts/tsconfig.json @@ -5,11 +5,12 @@ "skipLibCheck": true, "esModuleInterop": true, "target": "es2022", - "module": "node16", + "module": "node20", "sourceMap": false, "strict": true, "lib": ["es2022"], - "types": ["node"] + "types": ["node"], + "allowImportingTsExtensions": true }, "include": ["../src/@types", "./**/*.ts"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61d5ac07c8..d180eb8c9e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -314,9 +314,6 @@ importers: tar: specifier: ^7.5.8 version: 7.5.13 - tsx: - specifier: ^4.19.2 - version: 4.21.0 typescript: specifier: 5.9.3 version: 5.9.3 @@ -26560,6 +26557,7 @@ snapshots: get-tsconfig: 4.13.6 optionalDependencies: fsevents: 2.3.3 + optional: true tsyringe@4.10.0: dependencies: