From 00abcb808a869bcc4c40790c86da1a8a2041640e Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sun, 10 May 2026 12:57:44 +0200 Subject: [PATCH 1/7] Export ESM module --- .vscode/settings.json | 2 +- api/package.json | 11 ++++++++--- api/{tsconfig.json => tsconfig.base.json} | 3 --- api/tsconfig.cjs.json | 7 +++++++ api/tsconfig.esm.json | 9 +++++++++ 5 files changed, 25 insertions(+), 7 deletions(-) rename api/{tsconfig.json => tsconfig.base.json} (76%) create mode 100644 api/tsconfig.cjs.json create mode 100644 api/tsconfig.esm.json diff --git a/.vscode/settings.json b/.vscode/settings.json index a777efbd..be3aebd1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,7 @@ // Turn off tsc task auto detection since we have the necessary tasks as npm scripts "typescript.tsc.autoDetect": "off", "editor.formatOnSave": true, - "[typescript]": { + "[typescript][json][jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { "source.organizeImports": "explicit" diff --git a/api/package.json b/api/package.json index cd792cee..aebc0972 100644 --- a/api/package.json +++ b/api/package.json @@ -11,8 +11,11 @@ "API", "Environments" ], - "main": "./out/main.js", - "types": "./out/main.d.ts", + "exports": { + "import": "./out/esm/main.js", + "require": "./out/cjs/main.js", + "types": "./out/types/main.d.ts" + }, "engines": { "node": ">=22.21.1", "vscode": "^1.110.0" @@ -30,7 +33,9 @@ "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node -e \"process.exitCode = 1\"", "prepack": "npm run all:publish", "all:publish": "git clean -xfd . && npm install && npm run compile", - "compile": "tsc -b ./tsconfig.json", + "compile": "npm run compile:cjs && npm run compile:esm", + "compile:cjs": "tsc -b ./tsconfig.cjs.json", + "compile:esm": "tsc -b ./tsconfig.esm.json", "clean": "node -e \"const fs = require('fs'); fs.rmSync('./out', { recursive: true, force: true });\"" }, "devDependencies": { diff --git a/api/tsconfig.json b/api/tsconfig.base.json similarity index 76% rename from api/tsconfig.json rename to api/tsconfig.base.json index f46bf161..de49a776 100644 --- a/api/tsconfig.json +++ b/api/tsconfig.base.json @@ -1,11 +1,8 @@ { "compilerOptions": { "target": "ES2020", - "module": "commonjs", "lib": ["ES2020"], - "declaration": true, "strict": true, - "outDir": "./out", "rootDir": "src", "esModuleInterop": true, "skipLibCheck": true, diff --git a/api/tsconfig.cjs.json b/api/tsconfig.cjs.json new file mode 100644 index 00000000..8fb92e44 --- /dev/null +++ b/api/tsconfig.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "./out/cjs" + } +} diff --git a/api/tsconfig.esm.json b/api/tsconfig.esm.json new file mode 100644 index 00000000..80562f1f --- /dev/null +++ b/api/tsconfig.esm.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "esnext", + "outDir": "./out/esm", + "declaration": true, + "declarationDir": "./out/types" + } +} From 2e6f3da977be021208a77a8c38070a31abe0c7b0 Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sun, 10 May 2026 13:53:54 +0200 Subject: [PATCH 2/7] whoops --- api/package.json | 3 +-- api/tsconfig.base.json | 1 + api/tsconfig.esm.json | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/api/package.json b/api/package.json index aebc0972..fd82e86d 100644 --- a/api/package.json +++ b/api/package.json @@ -13,8 +13,7 @@ ], "exports": { "import": "./out/esm/main.js", - "require": "./out/cjs/main.js", - "types": "./out/types/main.d.ts" + "require": "./out/cjs/main.js" }, "engines": { "node": ">=22.21.1", diff --git a/api/tsconfig.base.json b/api/tsconfig.base.json index de49a776..1a9ed2b1 100644 --- a/api/tsconfig.base.json +++ b/api/tsconfig.base.json @@ -3,6 +3,7 @@ "target": "ES2020", "lib": ["ES2020"], "strict": true, + "declaration": true, "rootDir": "src", "esModuleInterop": true, "skipLibCheck": true, diff --git a/api/tsconfig.esm.json b/api/tsconfig.esm.json index 80562f1f..d513e2e0 100644 --- a/api/tsconfig.esm.json +++ b/api/tsconfig.esm.json @@ -2,8 +2,6 @@ "extends": "./tsconfig.base.json", "compilerOptions": { "module": "esnext", - "outDir": "./out/esm", - "declaration": true, - "declarationDir": "./out/types" + "outDir": "./out/esm" } } From 6984ad34c532c84ad45db41f7a433b1dab9b972a Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sun, 10 May 2026 15:15:03 +0200 Subject: [PATCH 3/7] ws --- package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8e4e1609..01eedcd1 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,9 @@ "bugs": { "url": "https://github.com/microsoft/vscode-python-environments/issues" }, + "workspaces": [ + "api" + ], "main": "./dist/extension.js", "l10n": "./l10n", "icon": "icon.png", @@ -124,7 +127,10 @@ "python-envs.workspaceSearchPaths": { "type": "array", "description": "%python-envs.workspaceSearchPaths.description%", - "default": [".venv", "*/.venv"], + "default": [ + ".venv", + "*/.venv" + ], "scope": "resource", "items": { "type": "string" From 3488256dda614074aa2f0e5754e744cd32d1ec63 Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sun, 10 May 2026 15:19:06 +0200 Subject: [PATCH 4/7] explicit types --- api/package.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/package.json b/api/package.json index fd82e86d..13be4aac 100644 --- a/api/package.json +++ b/api/package.json @@ -12,8 +12,14 @@ "Environments" ], "exports": { - "import": "./out/esm/main.js", - "require": "./out/cjs/main.js" + "import": { + "types": "./out/esm/main.d.ts", + "default": "./out/esm/main.js" + }, + "require": { + "types": "./out/cjs/main.d.ts", + "default": "./out/cjs/main.js" + } }, "engines": { "node": ">=22.21.1", From 5f23d1ce61cc0baef62d4183a9f94e067c7c8a6e Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sun, 10 May 2026 15:28:21 +0200 Subject: [PATCH 5/7] preinstall --- api/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/api/package.json b/api/package.json index 13be4aac..bd1b02c3 100644 --- a/api/package.json +++ b/api/package.json @@ -36,6 +36,7 @@ }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node -e \"process.exitCode = 1\"", + "preinstall": "npm run all:publish", "prepack": "npm run all:publish", "all:publish": "git clean -xfd . && npm install && npm run compile", "compile": "npm run compile:cjs && npm run compile:esm", From 72eb498fdf1b96cf57e6e6ee05170a74d646f689 Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Sun, 10 May 2026 15:34:11 +0200 Subject: [PATCH 6/7] revert --- api/package.json | 1 - package.json | 3 --- 2 files changed, 4 deletions(-) diff --git a/api/package.json b/api/package.json index bd1b02c3..13be4aac 100644 --- a/api/package.json +++ b/api/package.json @@ -36,7 +36,6 @@ }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node -e \"process.exitCode = 1\"", - "preinstall": "npm run all:publish", "prepack": "npm run all:publish", "all:publish": "git clean -xfd . && npm install && npm run compile", "compile": "npm run compile:cjs && npm run compile:esm", diff --git a/package.json b/package.json index 01eedcd1..c9c61c16 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,6 @@ "bugs": { "url": "https://github.com/microsoft/vscode-python-environments/issues" }, - "workspaces": [ - "api" - ], "main": "./dist/extension.js", "l10n": "./l10n", "icon": "icon.png", From 77099fec884f74ace4a82d74a152ea1f41d50160 Mon Sep 17 00:00:00 2001 From: "Philipp A." Date: Sun, 10 May 2026 19:12:00 +0200 Subject: [PATCH 7/7] smaller diff --- api/tsconfig.base.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/tsconfig.base.json b/api/tsconfig.base.json index 1a9ed2b1..67c9ca0b 100644 --- a/api/tsconfig.base.json +++ b/api/tsconfig.base.json @@ -2,8 +2,8 @@ "compilerOptions": { "target": "ES2020", "lib": ["ES2020"], - "strict": true, "declaration": true, + "strict": true, "rootDir": "src", "esModuleInterop": true, "skipLibCheck": true,