From 02aa0f0abe5d3aa20b3d77cd2477a07a8e0f4617 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Thu, 26 Oct 2023 08:06:53 +0200 Subject: [PATCH] chore(user-data, workspaces): add missing dependencies; always exclude electron from bundle; fix exports paths COMPASS-7361 (#5024) * chore(user-data): fix package dependencies * chore(webpack-config): always externalize electron package * chore(workspace): check that exports exist; fix missing export paths --- .../webpack-config-compass/src/externals.ts | 3 +++ package-lock.json | 21 ++++++++----------- packages/atlas-service/package.json | 8 +++++-- packages/compass-app-stores/package.json | 2 +- .../package.json | 2 +- packages/compass-editor/package.json | 2 +- .../compass-export-to-language/package.json | 2 +- packages/compass-field-store/package.json | 2 +- packages/compass-generative-ai/package.json | 2 +- packages/compass-import-export/package.json | 3 ++- .../package.json | 2 +- packages/compass-settings/package.json | 4 ++-- packages/compass-test-server/package.json | 2 +- packages/compass-user-data/package.json | 10 +++++---- packages/compass-utils/package.json | 2 +- packages/compass-welcome/package.json | 2 +- packages/connection-storage/package.json | 2 +- packages/mongodb-query-util/package.json | 2 +- scripts/create-workspace.js | 2 +- 19 files changed, 41 insertions(+), 34 deletions(-) diff --git a/configs/webpack-config-compass/src/externals.ts b/configs/webpack-config-compass/src/externals.ts index e828146a4d1..99246639311 100644 --- a/configs/webpack-config-compass/src/externals.ts +++ b/configs/webpack-config-compass/src/externals.ts @@ -1,6 +1,9 @@ import { execSync } from 'child_process'; export const sharedExternals: string[] = [ + // Electron should always stay external. For electron webpack target this + // happens automatically, for other targets we should never try to bundle it + 'electron', // Native Modules are very hard to bundle correctly with Webpack (and there is // not much reason to do so) so to make our lives easier, we will always // externalize them from the bulid diff --git a/package-lock.json b/package-lock.json index 4c7420c73df..85c1ad99a88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43360,7 +43360,6 @@ "version": "3.22.3", "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.3.tgz", "integrity": "sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==", - "dev": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } @@ -46366,6 +46365,7 @@ "@mongodb-js/compass-utils": "^0.5.2", "bson": "^6.0.0", "compass-preferences-model": "^2.15.3", + "electron": "^25.8.4", "hadron-document": "^8.4.2" }, "devDependencies": { @@ -46392,7 +46392,6 @@ "chai-as-promised": "^7.1.1", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^25.8.4", "eslint": "^7.25.0", "hadron-app-registry": "^9.0.12", "lodash": "^4.17.21", @@ -46424,6 +46423,7 @@ "@mongodb-js/compass-utils": "^0.5.2", "bson": "^6.0.0", "compass-preferences-model": "^2.15.3", + "electron": "^25.8.4", "hadron-document": "^8.4.2", "react": "^17.0.2" } @@ -47587,6 +47587,10 @@ "name": "@mongodb-js/compass-user-data", "version": "0.1.6", "license": "SSPL", + "dependencies": { + "write-file-atomic": "^5.0.1", + "zod": "^3.22.3" + }, "devDependencies": { "@mongodb-js/compass-logging": "^1.2.3", "@mongodb-js/compass-utils": "^0.5.2", @@ -47606,9 +47610,7 @@ "nyc": "^15.1.0", "prettier": "^2.7.1", "sinon": "^9.2.3", - "typescript": "^5.0.4", - "write-file-atomic": "^5.0.1", - "zod": "^3.22.3" + "typescript": "^5.0.4" } }, "packages/compass-user-data/node_modules/diff": { @@ -47624,7 +47626,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, "engines": { "node": ">=14" }, @@ -47654,7 +47655,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", - "dev": true, "dependencies": { "imurmurhash": "^0.1.4", "signal-exit": "^4.0.1" @@ -60537,8 +60537,7 @@ "signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==" }, "sinon": { "version": "9.2.4", @@ -60558,7 +60557,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", - "dev": true, "requires": { "imurmurhash": "^0.1.4", "signal-exit": "^4.0.1" @@ -93879,8 +93877,7 @@ "zod": { "version": "3.22.3", "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.3.tgz", - "integrity": "sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==", - "dev": true + "integrity": "sha512-EjIevzuJRiRPbVH4mGc8nApb/lVLKVpmUhAaR5R5doKGfAnGJ6Gr3CViAVjP+4FWSxCsybeWQdcgCtbX+7oZug==" } } } diff --git a/packages/atlas-service/package.json b/packages/atlas-service/package.json index e3daa96e9ad..9484efa53c7 100644 --- a/packages/atlas-service/package.json +++ b/packages/atlas-service/package.json @@ -19,7 +19,11 @@ "url": "https://github.com/mongodb-js/compass.git" }, "files": [ - "dist" + "dist", + "main.js", + "main.d.ts", + "renderer.js", + "renderer.d.ts" ], "license": "SSPL", "exports": { @@ -32,7 +36,7 @@ }, "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/packages/compass-app-stores/package.json b/packages/compass-app-stores/package.json index 50842d7766e..2045feae4dc 100644 --- a/packages/compass-app-stores/package.json +++ b/packages/compass-app-stores/package.json @@ -32,7 +32,7 @@ "types": "./dist/src/index.d.ts", "scripts": { "bootstrap": "npm run postcompile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "npm run webpack -- --mode production", "webpack": "webpack-compass", "postcompile": "tsc --emitDeclarationOnly", diff --git a/packages/compass-connection-import-export/package.json b/packages/compass-connection-import-export/package.json index 1a856ef358a..5bb8c2a52e9 100644 --- a/packages/compass-connection-import-export/package.json +++ b/packages/compass-connection-import-export/package.json @@ -35,7 +35,7 @@ "types": "./dist/index.d.ts", "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/packages/compass-editor/package.json b/packages/compass-editor/package.json index bad4e3a938f..2569e1c6d87 100644 --- a/packages/compass-editor/package.json +++ b/packages/compass-editor/package.json @@ -30,7 +30,7 @@ "types": "./dist/index.d.ts", "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/packages/compass-export-to-language/package.json b/packages/compass-export-to-language/package.json index 89faf03188a..4842e488f1f 100644 --- a/packages/compass-export-to-language/package.json +++ b/packages/compass-export-to-language/package.json @@ -35,7 +35,7 @@ }, "scripts": { "bootstrap": "npm run postcompile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "npm run webpack -- --mode production", "webpack": "webpack-compass", "postcompile": "tsc --emitDeclarationOnly", diff --git a/packages/compass-field-store/package.json b/packages/compass-field-store/package.json index 95e3b17e274..399555ba1ea 100644 --- a/packages/compass-field-store/package.json +++ b/packages/compass-field-store/package.json @@ -32,7 +32,7 @@ "types": "./dist/src/index.d.ts", "scripts": { "bootstrap": "npm run postcompile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "npm run webpack -- --mode production", "webpack": "webpack-compass", "postcompile": "tsc --emitDeclarationOnly", diff --git a/packages/compass-generative-ai/package.json b/packages/compass-generative-ai/package.json index 32aadcb0fe7..90bf161db47 100644 --- a/packages/compass-generative-ai/package.json +++ b/packages/compass-generative-ai/package.json @@ -35,7 +35,7 @@ "types": "./dist/src/index.d.ts", "scripts": { "bootstrap": "npm run postcompile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "npm run webpack -- --mode production", "webpack": "webpack-compass", "postcompile": "tsc --emitDeclarationOnly", diff --git a/packages/compass-import-export/package.json b/packages/compass-import-export/package.json index a62e9316100..7bc85ec1671 100644 --- a/packages/compass-import-export/package.json +++ b/packages/compass-import-export/package.json @@ -61,6 +61,7 @@ "@mongodb-js/compass-utils": "^0.5.2", "bson": "^6.0.0", "compass-preferences-model": "^2.15.3", + "electron": "^25.8.4", "hadron-document": "^8.4.2", "react": "^17.0.2" }, @@ -71,6 +72,7 @@ "@mongodb-js/compass-utils": "^0.5.2", "bson": "^6.0.0", "compass-preferences-model": "^2.15.3", + "electron": "^25.8.4", "hadron-document": "^8.4.2" }, "devDependencies": { @@ -97,7 +99,6 @@ "chai-as-promised": "^7.1.1", "debug": "^4.2.0", "depcheck": "^1.4.1", - "electron": "^25.8.4", "eslint": "^7.25.0", "hadron-app-registry": "^9.0.12", "lodash": "^4.17.21", diff --git a/packages/compass-maybe-protect-connection-string/package.json b/packages/compass-maybe-protect-connection-string/package.json index 57a631a3975..884eda5856a 100644 --- a/packages/compass-maybe-protect-connection-string/package.json +++ b/packages/compass-maybe-protect-connection-string/package.json @@ -35,7 +35,7 @@ "types": "./dist/index.d.ts", "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/packages/compass-settings/package.json b/packages/compass-settings/package.json index 13b6c1fbaa0..1c7dd51b786 100644 --- a/packages/compass-settings/package.json +++ b/packages/compass-settings/package.json @@ -24,7 +24,7 @@ "license": "SSPL", "main": "dist/index.js", "compass:main": "src/index.ts", - "types": "dist/index.d.ts", + "types": "dist/src/index.d.ts", "exports": { "require": "./dist/index.js", "browser": "./dist/browser.js" @@ -34,7 +34,7 @@ }, "scripts": { "bootstrap": "npm run postcompile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "npm run webpack -- --mode production", "webpack": "webpack-compass", "postcompile": "tsc --emitDeclarationOnly", diff --git a/packages/compass-test-server/package.json b/packages/compass-test-server/package.json index e5ca308db69..d08aba73be7 100644 --- a/packages/compass-test-server/package.json +++ b/packages/compass-test-server/package.json @@ -34,7 +34,7 @@ "types": "./dist/index.d.ts", "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/packages/compass-user-data/package.json b/packages/compass-user-data/package.json index 481e137f581..1916638fb44 100644 --- a/packages/compass-user-data/package.json +++ b/packages/compass-user-data/package.json @@ -33,7 +33,7 @@ "types": "./dist/index.d.ts", "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", @@ -48,6 +48,10 @@ "test-ci": "npm run test-cov", "reformat": "npm run prettier -- --write . && npm run eslint . --fix" }, + "dependencies": { + "write-file-atomic": "^5.0.1", + "zod": "^3.22.3" + }, "devDependencies": { "@mongodb-js/compass-logging": "^1.2.3", "@mongodb-js/compass-utils": "^0.5.2", @@ -67,8 +71,6 @@ "nyc": "^15.1.0", "prettier": "^2.7.1", "sinon": "^9.2.3", - "typescript": "^5.0.4", - "write-file-atomic": "^5.0.1", - "zod": "^3.22.3" + "typescript": "^5.0.4" } } diff --git a/packages/compass-utils/package.json b/packages/compass-utils/package.json index 0009c85e236..227ec649497 100644 --- a/packages/compass-utils/package.json +++ b/packages/compass-utils/package.json @@ -35,7 +35,7 @@ "types": "./dist/index.d.ts", "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/packages/compass-welcome/package.json b/packages/compass-welcome/package.json index 21af16bd56e..08445958fe1 100644 --- a/packages/compass-welcome/package.json +++ b/packages/compass-welcome/package.json @@ -35,7 +35,7 @@ }, "scripts": { "bootstrap": "npm run postcompile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "npm run webpack -- --mode production", "webpack": "webpack-compass", "postcompile": "tsc --emitDeclarationOnly", diff --git a/packages/connection-storage/package.json b/packages/connection-storage/package.json index df259885878..4bc0b697a45 100644 --- a/packages/connection-storage/package.json +++ b/packages/connection-storage/package.json @@ -36,7 +36,7 @@ }, "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/packages/mongodb-query-util/package.json b/packages/mongodb-query-util/package.json index ad60e2fec7b..1557ff1094b 100644 --- a/packages/mongodb-query-util/package.json +++ b/packages/mongodb-query-util/package.json @@ -34,7 +34,7 @@ "types": "./dist/index.d.ts", "scripts": { "bootstrap": "npm run compile", - "prepublishOnly": "npm run compile", + "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", "compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", "typecheck": "tsc -p tsconfig-lint.json --noEmit", "eslint": "eslint", diff --git a/scripts/create-workspace.js b/scripts/create-workspace.js index 76022c622ca..6e4ed29d8fd 100644 --- a/scripts/create-workspace.js +++ b/scripts/create-workspace.js @@ -257,7 +257,7 @@ async function createWorkspace({ types: isPlugin ? './dist/src/index.d.ts' : './dist/index.d.ts', scripts: { bootstrap: 'npm run compile', - prepublishOnly: 'npm run compile', + prepublishOnly: 'npm run compile && compass-scripts check-exports-exist', // For normal packages we are just compiling code with typescript, for // plugins (but only for them) we are using webpack to create independent // plugin packages