diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 25fa789321..8964f4c65e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,7 +7,8 @@ on: branches: [main] jobs: - publish-extension: + publish-vscode-extension: + name: Publish VSCode extension runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} environment: production @@ -47,6 +48,7 @@ jobs: extensionFile: ${{ steps.publishToOpenVSX.outputs.vsixPath }} publish-neovim-extension: + name: Publish Neovim extension runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} environment: production @@ -97,7 +99,7 @@ jobs: push-cursorless-talon: name: Push cursorless-talon subrepo runs-on: ubuntu-latest - needs: publish-extension + needs: publish-vscode-extension environment: production env: DEPLOY_SHA: ${{ github.event.workflow_run.head_sha }} diff --git a/package.json b/package.json index 4d26c2eb9e..e5cf5b354a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "license": "MIT", "packageManager": "pnpm@10.30.3", "type": "module", - "main": "index.js", "engines": { "node": ">=24.14.0" }, diff --git a/packages/cheatsheet-local/package.json b/packages/cheatsheet-local/package.json index efb43d28c7..64108ac472 100644 --- a/packages/cheatsheet-local/package.json +++ b/packages/cheatsheet-local/package.json @@ -5,11 +5,6 @@ "license": "MIT", "private": true, "type": "module", - "main": "./out/index.js", - "types": "./out/index.d.ts", - "exports": { - ".": "./out/index.js" - }, "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build", diff --git a/packages/cursorless-everywhere-talon-e2e/package.json b/packages/cursorless-everywhere-talon-e2e/package.json index 54276757c7..cdde669831 100644 --- a/packages/cursorless-everywhere-talon-e2e/package.json +++ b/packages/cursorless-everywhere-talon-e2e/package.json @@ -5,7 +5,6 @@ "license": "MIT", "private": true, "type": "module", - "main": "./out/index.js", "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build", diff --git a/packages/cursorless-everywhere-talon/package.json b/packages/cursorless-everywhere-talon/package.json index 22174951f7..e9c7462b65 100644 --- a/packages/cursorless-everywhere-talon/package.json +++ b/packages/cursorless-everywhere-talon/package.json @@ -5,7 +5,6 @@ "license": "MIT", "private": true, "type": "module", - "main": "./out/index.js", "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build", diff --git a/packages/cursorless-neovim-e2e/package.json b/packages/cursorless-neovim-e2e/package.json index 48b0fb09fb..dc82a86b6a 100644 --- a/packages/cursorless-neovim-e2e/package.json +++ b/packages/cursorless-neovim-e2e/package.json @@ -5,11 +5,6 @@ "license": "MIT", "private": true, "type": "module", - "main": "./out/index.js", - "types": "./out/index.d.ts", - "exports": { - ".": "./out/index.js" - }, "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build" diff --git a/packages/cursorless-neovim/package.json b/packages/cursorless-neovim/package.json index d0a949bd79..7dd316a219 100644 --- a/packages/cursorless-neovim/package.json +++ b/packages/cursorless-neovim/package.json @@ -5,10 +5,6 @@ "license": "MIT", "private": true, "main": "./out/index.cjs", - "types": "./out/index.d.ts", - "exports": { - ".": "./out/index.cjs" - }, "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build", diff --git a/packages/cursorless-org-docs/package.json b/packages/cursorless-org-docs/package.json index 9e48dc413c..88b46c0270 100644 --- a/packages/cursorless-org-docs/package.json +++ b/packages/cursorless-org-docs/package.json @@ -4,11 +4,6 @@ "description": "Cursorless documentation website", "license": "MIT", "private": true, - "main": "./out/index.js", - "types": "./out/index.d.ts", - "exports": { - ".": "./out/index.js" - }, "browserslist": { "production": [ ">0.5%", diff --git a/packages/cursorless-org/package.json b/packages/cursorless-org/package.json index 2341333905..7aa7bf0aa2 100644 --- a/packages/cursorless-org/package.json +++ b/packages/cursorless-org/package.json @@ -5,11 +5,6 @@ "license": "MIT", "private": true, "type": "module", - "main": "./out/index.js", - "types": "./out/index.d.ts", - "exports": { - ".": "./out/index.js" - }, "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build", diff --git a/packages/cursorless-vscode-e2e/package.json b/packages/cursorless-vscode-e2e/package.json index 3b8bc65922..1b9c9b1b98 100644 --- a/packages/cursorless-vscode-e2e/package.json +++ b/packages/cursorless-vscode-e2e/package.json @@ -5,11 +5,6 @@ "license": "MIT", "private": true, "type": "module", - "main": "./out/index.js", - "types": "./out/index.d.ts", - "exports": { - ".": "./out/index.js" - }, "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build" diff --git a/packages/cursorless-vscode-tutorial-webview/package.json b/packages/cursorless-vscode-tutorial-webview/package.json index 26ec95ad8c..7d3fd6c69d 100644 --- a/packages/cursorless-vscode-tutorial-webview/package.json +++ b/packages/cursorless-vscode-tutorial-webview/package.json @@ -5,7 +5,6 @@ "license": "MIT", "private": true, "type": "module", - "main": "./out/index.js", "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build", diff --git a/packages/meta-updater/package.json b/packages/meta-updater/package.json index 4b4006d9a5..397a76c708 100644 --- a/packages/meta-updater/package.json +++ b/packages/meta-updater/package.json @@ -16,7 +16,6 @@ "@types/js-yaml": "^4.0.9", "@types/lodash-es": "^4.17.12", "@types/normalize-path": "^3.0.2", - "esbuild": "^0.27.4", "js-yaml": "^4.1.1", "lodash-es": "^4.17.23", "normalize-path": "^3.0.0", diff --git a/packages/meta-updater/src/metaUpdater.ts b/packages/meta-updater/src/metaUpdater.ts index f6e7d0ee89..6a60c1664a 100644 --- a/packages/meta-updater/src/metaUpdater.ts +++ b/packages/meta-updater/src/metaUpdater.ts @@ -10,8 +10,9 @@ import { textFormat } from "./textFormat"; import { updateLanguageMdx } from "./updateLanguageMdx"; import { updatePackageJson } from "./updatePackageJson"; import { getScopeTypeTypes, updateScopeMdx } from "./updateScopeMdx"; -import { updateTSConfig } from "./updateTSConfig"; import { updatesScopeSupportFacetInfos } from "./updatesScopeSupportFacetInfos"; +import { updateTSConfig } from "./updateTSConfig"; +import { updateTSConfigBase } from "./updateTSConfigBase"; export const updater = async (workspaceDir: string) => { const pnpmLockfile = await readWantedLockfile(workspaceDir, { @@ -31,6 +32,7 @@ export const updater = async (workspaceDir: string) => { files: { ["package.json"]: updatePackageJson.bind(null, context), ["tsconfig.json"]: updateTSConfig.bind(null, context), + ["tsconfig.base.json"]: updateTSConfigBase.bind(null, context), ["data/scopeSupportFacetInfos.md"]: updatesScopeSupportFacetInfos, ...Object.fromEntries( Object.keys(languageScopeSupport).map((languageId) => [ diff --git a/packages/meta-updater/src/updatePackageJson.ts b/packages/meta-updater/src/updatePackageJson.ts index bab0dd56ac..cc57597def 100644 --- a/packages/meta-updater/src/updatePackageJson.ts +++ b/packages/meta-updater/src/updatePackageJson.ts @@ -5,7 +5,7 @@ import type { PackageJson } from "type-fest"; import type { Context } from "./Context"; import { getCursorlessVscodeFields } from "./getCursorlessVscodeFields"; -const LIB_ENTRY_POINT = "./src/index.ts"; +export const LIB_ENTRY_POINT = "src/index.ts"; /** * Given a package.json, update it to match our conventions. This function is @@ -26,10 +26,15 @@ export async function updatePackageJson( const input: PackageJson = (rawInput ?? {}) as PackageJson; /** Directory of the package whose package.json we are updating */ const packageDir = options.dir; - /** Whether we are updating the top-level package.json */ const isRoot = packageDir === workspaceDir; + const isLib = !isRoot && !input.private; + const isCursorlessVscode = input.name === "@cursorless/cursorless-vscode"; + const isCursorlessNeovim = input.name === "@cursorless/cursorless-neovim"; + const isCursorlessOrgDocs = input.name === "@cursorless/cursorless-org-docs"; + const isCursorlessTestHarness = input.name === "@cursorless/test-harness"; + if (input.description == null || input.description === "") { throw new Error(`No description found in ${packageDir}/package.json`); } @@ -39,23 +44,29 @@ export async function updatePackageJson( ? input.name : `@cursorless/${input.name}`; - const isLib = !isRoot && !input.private; - - const exportFields: Partial = (() => { - if (!isLib) { - return {}; - } + if (isLib) { const exports = input.exports != null && typeof input.exports === "object" && !Array.isArray(input.exports) ? input.exports : {}; - exports["."] = LIB_ENTRY_POINT; - return { exports }; - })(); - - const isCursorlessVscode = input.name === "@cursorless/cursorless-vscode"; + exports["."] = `./${LIB_ENTRY_POINT}`; + input.exports = exports; + } else { + delete input.types; + delete input.exports; + // Extensions need a main field, but other non-lib packages shouldn't have + // one. The test harness is a special case since it's technically not a + // library but still requires main for the neovim tests. + if ( + !isCursorlessVscode && + !isCursorlessNeovim && + !isCursorlessTestHarness + ) { + delete input.main; + } + } const extraFields = isCursorlessVscode ? getCursorlessVscodeFields(input) @@ -65,13 +76,8 @@ export async function updatePackageJson( ...input, name, license: "MIT", - type: - name === "@cursorless/cursorless-org-docs" || - name === "@cursorless/cursorless-neovim" - ? undefined - : "module", + type: isCursorlessOrgDocs || isCursorlessNeovim ? undefined : "module", scripts: await getScripts(input.scripts, name, packageDir, isRoot, isLib), - ...exportFields, ...extraFields, }; diff --git a/packages/meta-updater/src/updateTSConfigBase.ts b/packages/meta-updater/src/updateTSConfigBase.ts new file mode 100644 index 0000000000..f7f0c153c7 --- /dev/null +++ b/packages/meta-updater/src/updateTSConfigBase.ts @@ -0,0 +1,47 @@ +import type { FormatPluginFnOptions } from "@pnpm/meta-updater"; +import * as fs from "fs/promises"; +import type { PackageJson, TsConfigJson } from "type-fest"; +import type { Context } from "./Context"; +import { LIB_ENTRY_POINT } from "./updatePackageJson"; + +export async function updateTSConfigBase( + { workspaceDir, pnpmLockfile }: Context, + rawInput: object | null, + options: FormatPluginFnOptions, +): Promise { + /** Directory of the package whose tsconfig.json we are updating */ + const packageDir = options.dir; + + if (packageDir !== workspaceDir) { + return undefined; + } + + /** The input tsconfig.json that should be checked / updated */ + const input: TsConfigJson = (rawInput ?? {}) as TsConfigJson; + + const packages = Object.keys(pnpmLockfile.importers).filter( + (importer) => importer !== ".", + ); + + const paths: Record = {}; + + for (const packagePath of packages) { + const packageName = packagePath.replace("packages/", "@cursorless/"); + const packageJsonPath = `${packageDir}/${packagePath}/package.json`; + const packageJson = JSON.parse( + await fs.readFile(packageJsonPath, "utf-8"), + ) as PackageJson; + + if (!packageJson.private) { + paths[packageName] = [`./${packagePath}/${LIB_ENTRY_POINT}`]; + } + } + + return { + ...rawInput, + compilerOptions: { + ...input.compilerOptions, + paths, + }, + }; +} diff --git a/packages/test-harness/README.md b/packages/test-harness/README.md index 0b64f2fcb6..5ed7beb20f 100644 --- a/packages/test-harness/README.md +++ b/packages/test-harness/README.md @@ -4,4 +4,4 @@ This package contains the machinery used to test Cursorless, both in CI and loca This package bundles tests into `.mjs` files and includes scripts used to run tests. -Note that we currently have a hack where the `package.json` here appears as if it is only used for Neovim. That is because none of our other test runners require a `package.json`, so they are happy to ignore fields such as `main` and `types` that are required for Neovim to be able to import the test harness. See [#2564](https://github.com/cursorless-dev/cursorless/issues/2564) to track progress on a more elegant solution. +Note that we currently have a hack where the `package.json` here appears as if it is only used for Neovim. That is because none of our other test runners require a `package.json`, so they are happy to ignore fields such as `main` that are required for Neovim to be able to import the test harness. See [#2564](https://github.com/cursorless-dev/cursorless/issues/2564) to track progress on a more elegant solution. diff --git a/packages/test-harness/package.json b/packages/test-harness/package.json index 85688908a6..938513020c 100644 --- a/packages/test-harness/package.json +++ b/packages/test-harness/package.json @@ -6,12 +6,6 @@ "private": true, "type": "module", "main": "./out/extensionTestsNeovim.cjs", - "types": "./out/extensionTestsNeovim.d.ts", - "exports": { - ".": { - "default": "./out/extensionTestsNeovim.cjs" - } - }, "scripts": { "typecheck": "tsc", "clean": "rm -rf ./out tsconfig.tsbuildinfo ./dist ./build", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5e2a09a62c..5e28ad14dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -764,9 +764,6 @@ importers: '@types/normalize-path': specifier: ^3.0.2 version: 3.0.2 - esbuild: - specifier: ^0.27.4 - version: 0.27.4 js-yaml: specifier: ^4.1.1 version: 4.1.1