From be715f253efaabd92cf7da1b50bb411d09c77911 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Mon, 13 Jan 2025 12:37:32 -0500 Subject: [PATCH 1/3] Add esbuild script for esm / commonjs shared builds Signed-off-by: Ian Bolton --- shared/build-shared.js | 28 ++++++++++++++++++++++++++++ shared/package.json | 6 ++++-- shared/tsconfig.json | 4 +++- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 shared/build-shared.js diff --git a/shared/build-shared.js b/shared/build-shared.js new file mode 100644 index 00000000..7ebd0665 --- /dev/null +++ b/shared/build-shared.js @@ -0,0 +1,28 @@ +import esbuild from "esbuild"; + +esbuild + .build({ + entryPoints: ["src/index.ts"], + bundle: true, + platform: "node", + sourcemap: true, + outdir: "dist", + format: "esm", + target: "esnext", + splitting: true, + outExtension: { ".js": ".esm.js" }, + }) + .catch(() => process.exit(1)); + +esbuild + .build({ + entryPoints: ["src/index.ts"], + bundle: true, + platform: "node", + sourcemap: true, + outdir: "dist", + format: "cjs", + target: "es2015", + outExtension: { ".js": ".cjs.js" }, + }) + .catch(() => process.exit(1)); diff --git a/shared/package.json b/shared/package.json index 37e0ed87..e5a26673 100644 --- a/shared/package.json +++ b/shared/package.json @@ -2,14 +2,16 @@ "name": "@editor-extensions/shared", "version": "0.0.1", "private": true, - "main": "./dist/index.js", + "main": "./dist/index.cjs.js", + "type": "module", + "module": "./dist/index.esm.js", "types": "./dist/index.d.ts", "scripts": { "clean": "rimraf dist", "lint": "eslint .", "lint:fix": "eslint --fix .", "prebuild": "npm run clean", - "build": "tsc --build", + "build": "node build-shared.js && tsc --emitDeclarationOnly", "dev": "tsc --build --watch --preserveWatchOutput" }, "lint-staged": { diff --git a/shared/tsconfig.json b/shared/tsconfig.json index c21e4bd7..06b4a517 100644 --- a/shared/tsconfig.json +++ b/shared/tsconfig.json @@ -7,7 +7,9 @@ "declaration": true, "declarationMap": true, "sourceMap": true, - "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" + "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo", + "module": "ESNext", + "moduleResolution": "Node" }, "include": ["src/**/*.ts"], "exclude": ["dist", "node_modules"] From 82bec099a0d8bfa15bdc7a65e13959f308b77770 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Mon, 13 Jan 2025 15:34:52 -0500 Subject: [PATCH 2/3] Replace esbuild with vite library mode step Signed-off-by: Ian Bolton --- shared/build-shared.js | 28 ---------------------------- shared/package.json | 5 ++++- shared/vite.config.js | 22 ++++++++++++++++++++++ tsconfig.json | 8 +------- 4 files changed, 27 insertions(+), 36 deletions(-) delete mode 100644 shared/build-shared.js create mode 100644 shared/vite.config.js diff --git a/shared/build-shared.js b/shared/build-shared.js deleted file mode 100644 index 7ebd0665..00000000 --- a/shared/build-shared.js +++ /dev/null @@ -1,28 +0,0 @@ -import esbuild from "esbuild"; - -esbuild - .build({ - entryPoints: ["src/index.ts"], - bundle: true, - platform: "node", - sourcemap: true, - outdir: "dist", - format: "esm", - target: "esnext", - splitting: true, - outExtension: { ".js": ".esm.js" }, - }) - .catch(() => process.exit(1)); - -esbuild - .build({ - entryPoints: ["src/index.ts"], - bundle: true, - platform: "node", - sourcemap: true, - outdir: "dist", - format: "cjs", - target: "es2015", - outExtension: { ".js": ".cjs.js" }, - }) - .catch(() => process.exit(1)); diff --git a/shared/package.json b/shared/package.json index e5a26673..82db4000 100644 --- a/shared/package.json +++ b/shared/package.json @@ -11,9 +11,12 @@ "lint": "eslint .", "lint:fix": "eslint --fix .", "prebuild": "npm run clean", - "build": "node build-shared.js && tsc --emitDeclarationOnly", + "build": "vite build && tsc --emitDeclarationOnly", "dev": "tsc --build --watch --preserveWatchOutput" }, + "devDependencies": { + "vite": "^5.4.9" + }, "lint-staged": { "*.{js,cjs,mjs,ts,cts,mts}": "eslint --fix", "*.json": "prettier --write" diff --git a/shared/vite.config.js b/shared/vite.config.js new file mode 100644 index 00000000..a909bbc8 --- /dev/null +++ b/shared/vite.config.js @@ -0,0 +1,22 @@ +import { resolve } from "path"; +import { defineConfig } from "vite"; + +export default defineConfig({ + build: { + lib: { + entry: resolve(__dirname, "src/index.ts"), + name: "Shared", + fileName: (format) => `index.${format}.js`, + formats: ["esm", "cjs"], + }, + rollupOptions: { + external: ["react", "react-dom"], + output: { + globals: { + react: "React", + "react-dom": "ReactDOM", + }, + }, + }, + }, +}); diff --git a/tsconfig.json b/tsconfig.json index 9f8f74fb..30144882 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,11 +9,5 @@ "baseUrl": ".", "composite": true, "declaration": true - }, - - "references": [ - { "path": "./shared" }, - { "path": "./vscode" }, - { "path": "./webview-ui" } - ] + } } From 1a98c5ecaa904aed3e4395a640886c4de326d493 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Tue, 28 Jan 2025 10:56:03 -0500 Subject: [PATCH 3/3] Additional modifications More work to: - remove the remaining typescript composite configs - enhance the vite config for shared package - fixup the dev scripts so all workspaces can have their builders running in watch mode Signed-off-by: Scott J Dickerson --- package-lock.json | 572 +++++++++++++++++++++++++++++++++++++-- package.json | 11 +- shared/package.json | 21 +- shared/tsconfig.json | 4 +- shared/vite.config.js | 17 +- tsconfig.json | 4 +- vscode/package.json | 4 +- vscode/tsconfig.json | 1 - webview-ui/tsconfig.json | 1 - 9 files changed, 583 insertions(+), 52 deletions(-) diff --git a/package-lock.json b/package-lock.json index b42983d4..8a9f5458 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ }, "devDependencies": { "@eslint/js": "^9.11.1", + "@rollup/plugin-node-resolve": "^16.0.0", "@types/fs-extra": "^11.0.4", "@types/js-yaml": "^4.0.9", "@types/node": "22.x", @@ -53,7 +54,8 @@ "tar": "^7.4.3", "typescript": "^5.6.3", "typescript-eslint": "^8.14.0", - "unzipper": "^0.12.3" + "unzipper": "^0.12.3", + "wait-on": "^8.0.2" }, "engines": { "node": ">=22.9.0", @@ -1197,6 +1199,23 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@hapi/hoek": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", + "integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@hapi/topo": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz", + "integrity": "sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@hapi/hoek": "^9.0.0" + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -1750,6 +1769,88 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.0.tgz", + "integrity": "sha512-0FPvAeVUT/zdWoO0jnb/V5BlBsUSNfkIOtFHzMO4H9MOklrmQFY6FduVHKucNb/aTFxvnGhj4MNj/T1oNdDfNg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve/node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz", + "integrity": "sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.27.2", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.27.2.tgz", @@ -1762,7 +1863,8 @@ "optional": true, "os": [ "android" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-android-arm64": { "version": "4.27.2", @@ -1776,7 +1878,8 @@ "optional": true, "os": [ "android" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-darwin-arm64": { "version": "4.27.2", @@ -1790,7 +1893,8 @@ "optional": true, "os": [ "darwin" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-darwin-x64": { "version": "4.27.2", @@ -1804,7 +1908,8 @@ "optional": true, "os": [ "darwin" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-freebsd-arm64": { "version": "4.27.2", @@ -1818,7 +1923,8 @@ "optional": true, "os": [ "freebsd" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-freebsd-x64": { "version": "4.27.2", @@ -1832,7 +1938,8 @@ "optional": true, "os": [ "freebsd" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { "version": "4.27.2", @@ -1846,7 +1953,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { "version": "4.27.2", @@ -1860,7 +1968,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm64-gnu": { "version": "4.27.2", @@ -1874,7 +1983,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-arm64-musl": { "version": "4.27.2", @@ -1888,7 +1998,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { "version": "4.27.2", @@ -1902,7 +2013,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { "version": "4.27.2", @@ -1916,7 +2028,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-s390x-gnu": { "version": "4.27.2", @@ -1930,7 +2043,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-linux-x64-gnu": { "version": "4.9.5", @@ -1957,7 +2071,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-win32-arm64-msvc": { "version": "4.27.2", @@ -1971,7 +2086,8 @@ "optional": true, "os": [ "win32" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-win32-ia32-msvc": { "version": "4.27.2", @@ -1985,7 +2101,8 @@ "optional": true, "os": [ "win32" - ] + ], + "peer": true }, "node_modules/@rollup/rollup-win32-x64-msvc": { "version": "4.27.2", @@ -1999,7 +2116,32 @@ "optional": true, "os": [ "win32" - ] + ], + "peer": true + }, + "node_modules/@sideway/address": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz", + "integrity": "sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@hapi/hoek": "^9.0.0" + } + }, + "node_modules/@sideway/formula": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sideway/formula/-/formula-3.0.1.tgz", + "integrity": "sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@sideway/pinpoint": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", + "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", + "dev": true, + "license": "BSD-3-Clause" }, "node_modules/@sinclair/typebox": { "version": "0.27.8", @@ -2285,6 +2427,13 @@ "@types/react": "*" } }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -3600,6 +3749,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/azure-devops-node-api": { "version": "12.5.0", "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-12.5.0.tgz", @@ -4675,6 +4836,16 @@ "dev": true, "license": "MIT" }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", @@ -5605,6 +5776,13 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -5876,6 +6054,27 @@ "tabbable": "^6.2.0" } }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -6764,9 +6963,9 @@ } }, "node_modules/is-core-module": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", - "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", "dev": true, "license": "MIT", "dependencies": { @@ -6936,6 +7135,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true, + "license": "MIT" + }, "node_modules/is-negative-zero": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", @@ -7495,6 +7701,20 @@ "node": ">= 10.13.0" } }, + "node_modules/joi": { + "version": "17.13.3", + "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.3.tgz", + "integrity": "sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@hapi/hoek": "^9.3.0", + "@hapi/topo": "^5.1.0", + "@sideway/address": "^4.1.5", + "@sideway/formula": "^3.0.1", + "@sideway/pinpoint": "^2.0.0" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -8836,7 +9056,6 @@ "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "dev": true, "license": "MIT", - "optional": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -10138,6 +10357,13 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true, + "license": "MIT" + }, "node_modules/pump": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", @@ -10763,7 +10989,8 @@ "optional": true, "os": [ "linux" - ] + ], + "peer": true }, "node_modules/run-parallel": { "version": "1.2.0", @@ -11893,6 +12120,13 @@ "dev": true, "license": "MIT" }, + "node_modules/tiny-invariant": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", + "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==", + "dev": true, + "license": "MIT" + }, "node_modules/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", @@ -12106,6 +12340,19 @@ "node": ">= 0.8.0" } }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typed-array-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz", @@ -12611,6 +12858,165 @@ } } }, + "node_modules/vite-plugin-checker": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/vite-plugin-checker/-/vite-plugin-checker-0.8.0.tgz", + "integrity": "sha512-UA5uzOGm97UvZRTdZHiQVYFnd86AVn8EVaD4L3PoVzxH+IZSfaAw14WGFwX9QS23UW3lV/5bVKZn6l0w+q9P0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.12.13", + "ansi-escapes": "^4.3.0", + "chalk": "^4.1.1", + "chokidar": "^3.5.1", + "commander": "^8.0.0", + "fast-glob": "^3.2.7", + "fs-extra": "^11.1.0", + "npm-run-path": "^4.0.1", + "strip-ansi": "^6.0.0", + "tiny-invariant": "^1.1.0", + "vscode-languageclient": "^7.0.0", + "vscode-languageserver": "^7.0.0", + "vscode-languageserver-textdocument": "^1.0.1", + "vscode-uri": "^3.0.2" + }, + "engines": { + "node": ">=14.16" + }, + "peerDependencies": { + "@biomejs/biome": ">=1.7", + "eslint": ">=7", + "meow": "^9.0.0", + "optionator": "^0.9.1", + "stylelint": ">=13", + "typescript": "*", + "vite": ">=2.0.0", + "vls": "*", + "vti": "*", + "vue-tsc": "~2.1.6" + }, + "peerDependenciesMeta": { + "@biomejs/biome": { + "optional": true + }, + "eslint": { + "optional": true + }, + "meow": { + "optional": true + }, + "optionator": { + "optional": true + }, + "stylelint": { + "optional": true + }, + "typescript": { + "optional": true + }, + "vls": { + "optional": true + }, + "vti": { + "optional": true + }, + "vue-tsc": { + "optional": true + } + } + }, + "node_modules/vite-plugin-checker/node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/vite-plugin-checker/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/vite-plugin-checker/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/vite-plugin-checker/node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/vite-plugin-checker/node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/vite-plugin-checker/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/vite-plugin-checker/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/vscode-jsonrpc": { "version": "8.2.1", "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.1.tgz", @@ -12620,6 +13026,100 @@ "node": ">=14.0.0" } }, + "node_modules/vscode-languageclient": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-7.0.0.tgz", + "integrity": "sha512-P9AXdAPlsCgslpP9pRxYPqkNYV7Xq8300/aZDpO35j1fJm/ncize8iGswzYlcvFw5DQUx4eVk+KvfXdL0rehNg==", + "dev": true, + "license": "MIT", + "dependencies": { + "minimatch": "^3.0.4", + "semver": "^7.3.4", + "vscode-languageserver-protocol": "3.16.0" + }, + "engines": { + "vscode": "^1.52.0" + } + }, + "node_modules/vscode-languageclient/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/vscode-languageclient/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/vscode-languageserver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-7.0.0.tgz", + "integrity": "sha512-60HTx5ID+fLRcgdHfmz0LDZAXYEV68fzwG0JWwEPBode9NuMYTIxuYXPg4ngO8i8+Ou0lM7y6GzaYWbiDL0drw==", + "dev": true, + "license": "MIT", + "dependencies": { + "vscode-languageserver-protocol": "3.16.0" + }, + "bin": { + "installServerIntoExtension": "bin/installServerIntoExtension" + } + }, + "node_modules/vscode-languageserver-protocol": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0.tgz", + "integrity": "sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A==", + "dev": true, + "license": "MIT", + "dependencies": { + "vscode-jsonrpc": "6.0.0", + "vscode-languageserver-types": "3.16.0" + } + }, + "node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0.tgz", + "integrity": "sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0.0 || >=10.0.0" + } + }, + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", + "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-languageserver-types": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz", + "integrity": "sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-uri": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", + "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==", + "dev": true, + "license": "MIT" + }, "node_modules/vscode-webview": { "version": "1.0.1-beta.1", "resolved": "https://registry.npmjs.org/vscode-webview/-/vscode-webview-1.0.1-beta.1.tgz", @@ -12643,6 +13143,26 @@ "node": ">=12" } }, + "node_modules/wait-on": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-8.0.2.tgz", + "integrity": "sha512-qHlU6AawrgAIHlueGQHQ+ETcPLAauXbnoTKl3RKq20W0T8x0DKVAo5xWIYjHSyvHxQlcYbFdR0jp4T9bDVITFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "axios": "^1.7.9", + "joi": "^17.13.3", + "lodash": "^4.17.21", + "minimist": "^1.2.8", + "rxjs": "^7.8.1" + }, + "bin": { + "wait-on": "bin/wait-on" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.2.tgz", @@ -13295,7 +13815,11 @@ }, "shared": { "name": "@editor-extensions/shared", - "version": "0.0.6" + "version": "0.0.6", + "devDependencies": { + "vite": "^5.4.9", + "vite-plugin-checker": "^0.8.0" + } }, "vscode": { "name": "konveyor-ai", diff --git a/package.json b/package.json index 542b6b6f..37757403 100644 --- a/package.json +++ b/package.json @@ -43,14 +43,13 @@ "prepare": "husky", "postinstall": "npm run build -w shared", "clean": "rimraf ./dist ./downloaded_assets && npm run clean --workspaces --if-present", - "clean:all": "npm run clean && rimraf ./node_modules ./**/node_modules/", + "clean:all": "npm run clean && rimraf ./node_modules ./**/node_modules/ ./**/tsconfig.tsbuildinfo", "lint": "eslint ./scripts && npm run lint --workspaces --if-present", "lint:fix": "npm run lint:fix --workspaces --if-present", - "predev": "npm run build -w shared", "dev": "concurrently -c auto 'npm:dev:shared' 'npm:dev:webview-ui' 'npm:dev:vscode'", "dev:shared": "npm run dev -w shared", - "dev:webview-ui": "npm run start -w webview-ui", - "dev:vscode": "npm run dev -w vscode", + "dev:webview-ui": "wait-on -d 500 shared/dist/index.mjs && npm run start -w webview-ui", + "dev:vscode": "wait-on -d 500 shared/dist/index.mjs && npm run dev -w vscode", "build": "npm run build --workspaces --if-present", "collect-assets": "rimraf ./downloaded_assets && node ./scripts/collect-assets.js", "dist": "rimraf ./dist && node ./scripts/copy-dist.js", @@ -63,6 +62,7 @@ }, "devDependencies": { "@eslint/js": "^9.11.1", + "@rollup/plugin-node-resolve": "^16.0.0", "@types/fs-extra": "^11.0.4", "@types/js-yaml": "^4.0.9", "@types/node": "22.x", @@ -88,7 +88,8 @@ "tar": "^7.4.3", "typescript": "^5.6.3", "typescript-eslint": "^8.14.0", - "unzipper": "^0.12.3" + "unzipper": "^0.12.3", + "wait-on": "^8.0.2" }, "dependencies": { "fs-extra": "^11.2.0", diff --git a/shared/package.json b/shared/package.json index 40ed3f88..17e50cd6 100644 --- a/shared/package.json +++ b/shared/package.json @@ -2,20 +2,31 @@ "name": "@editor-extensions/shared", "version": "0.0.6", "private": true, - "main": "./dist/index.cjs.js", "type": "module", - "module": "./dist/index.esm.js", "types": "./dist/index.d.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/index.cjs", + "import": "./dist/index.mjs" + }, + "./package.json": "./package.json" + }, "scripts": { "clean": "rimraf dist", "lint": "eslint .", "lint:fix": "eslint --fix .", "prebuild": "npm run clean", - "build": "vite build && tsc --emitDeclarationOnly", - "dev": "tsc --build --watch --preserveWatchOutput" + "build": "vite build && tsc", + "dev": "concurrently -c auto 'npm:dev:*'", + "dev:types": "tsc --watch", + "dev:build": "vite build --watch" }, "devDependencies": { - "vite": "^5.4.9" + "vite": "^5.4.9", + "vite-plugin-checker": "^0.8.0" }, "lint-staged": { "*.{js,cjs,mjs,ts,cts,mts}": "eslint --fix", diff --git a/shared/tsconfig.json b/shared/tsconfig.json index 06b4a517..dfaab978 100644 --- a/shared/tsconfig.json +++ b/shared/tsconfig.json @@ -3,11 +3,9 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./src", - "composite": true, + "emitDeclarationOnly": true, "declaration": true, "declarationMap": true, - "sourceMap": true, - "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo", "module": "ESNext", "moduleResolution": "Node" }, diff --git a/shared/vite.config.js b/shared/vite.config.js index a909bbc8..48bacfba 100644 --- a/shared/vite.config.js +++ b/shared/vite.config.js @@ -1,22 +1,21 @@ import { resolve } from "path"; import { defineConfig } from "vite"; +import nodeResolve from "@rollup/plugin-node-resolve"; +import checker from "vite-plugin-checker"; export default defineConfig({ + plugins: [checker({ typescript: true })], build: { lib: { entry: resolve(__dirname, "src/index.ts"), name: "Shared", - fileName: (format) => `index.${format}.js`, - formats: ["esm", "cjs"], + fileName: (format) => (format === "es" ? "index.mjs" : "index.cjs"), + formats: ["es", "cjs"], }, + minify: false, + sourcemap: true, rollupOptions: { - external: ["react", "react-dom"], - output: { - globals: { - react: "React", - "react-dom": "ReactDOM", - }, - }, + plugins: [nodeResolve()], // this is a library so don't package libraries }, }, }); diff --git a/tsconfig.json b/tsconfig.json index 30144882..c480eba1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "baseUrl": ".", - "composite": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/vscode/package.json b/vscode/package.json index 69b43cf0..eaa4c0e7 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -723,11 +723,11 @@ "lint:fix": "eslint --fix .", "prebuild": "npm run clean", "build": "npm run compile", - "compile": "tsc -b && webpack --mode production", + "compile": "tsc && webpack --mode production", "dev": "npm run watch", "watch": "webpack --watch --mode development", "test:local": "mocha --require ts-node/register src/**/__tests__/*test.ts", - "test": "npm run test:local && npm run compile && vscode-test" + "test": "npm run compile && npm run test:local && vscode-test" }, "lint-staged": { "*.{js,cjs,mjs,ts,cts,mts}": "eslint --fix", diff --git a/vscode/tsconfig.json b/vscode/tsconfig.json index 18b0ea54..600c4c8e 100644 --- a/vscode/tsconfig.json +++ b/vscode/tsconfig.json @@ -9,7 +9,6 @@ "sourceMap": true, "rootDir": "src", "strict": true, - "composite": true, "declaration": true }, "include": ["src/**/*.ts"] diff --git a/webview-ui/tsconfig.json b/webview-ui/tsconfig.json index d525bc4c..29037307 100644 --- a/webview-ui/tsconfig.json +++ b/webview-ui/tsconfig.json @@ -20,7 +20,6 @@ "noImplicitAny": false, "allowJs": false, "baseUrl": ".", - "composite": true, "outDir": "dist", "declaration": true, "noEmit": false