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..13be4aac 100644 --- a/api/package.json +++ b/api/package.json @@ -11,8 +11,16 @@ "API", "Environments" ], - "main": "./out/main.js", - "types": "./out/main.d.ts", + "exports": { + "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", "vscode": "^1.110.0" @@ -30,7 +38,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 84% rename from api/tsconfig.json rename to api/tsconfig.base.json index f46bf161..67c9ca0b 100644 --- a/api/tsconfig.json +++ b/api/tsconfig.base.json @@ -1,11 +1,9 @@ { "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..d513e2e0 --- /dev/null +++ b/api/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "esnext", + "outDir": "./out/esm" + } +} diff --git a/package.json b/package.json index 8e4e1609..c9c61c16 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,10 @@ "python-envs.workspaceSearchPaths": { "type": "array", "description": "%python-envs.workspaceSearchPaths.description%", - "default": [".venv", "*/.venv"], + "default": [ + ".venv", + "*/.venv" + ], "scope": "resource", "items": { "type": "string"