From a509d4a1481d8d029215ae91277632ddbb8cf79f Mon Sep 17 00:00:00 2001 From: hackolade-bot Date: Thu, 29 May 2025 15:55:23 +0300 Subject: [PATCH 1/5] Fix build of plugin to allow its usage in the browser --- esbuild.package.js | 65 +++++++++++++++++++++++++++++++++++++++++++++- package-lock.json | 1 + package.json | 1 + 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/esbuild.package.js b/esbuild.package.js index 869b574..07669e8 100644 --- a/esbuild.package.js +++ b/esbuild.package.js @@ -26,7 +26,16 @@ esbuild outdir: RELEASE_FOLDER_PATH, minify: true, logLevel: 'info', - external: ['electron', 'lodash'], + external: [ + 'electron', + 'lodash', + 'debug', + 'https-proxy-agent', + 'http-proxy-agent', + 'fs-extra', + 'big.js', + 'node-fetch', + ], plugins: [ clean({ patterns: [DEFAULT_RELEASE_FOLDER_PATH], @@ -37,6 +46,60 @@ esbuild to: [path.join('node_modules', 'lodash')], }, }), + copy({ + assets: { + from: [path.join('node_modules', 'debug', '**', '*')], + to: [path.join('node_modules', 'debug')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'http-proxy-agent', '**', '*')], + to: [path.join('node_modules', 'http-proxy-agent')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'https-proxy-agent', '**', '*')], + to: [path.join('node_modules', 'https-proxy-agent')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'fs-extra', '**', '*')], + to: [path.join('node_modules', 'fs-extra')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'big.js', 'big.js')], + to: [path.join('node_modules', 'big.js', 'big.js')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'big.js', 'big.mjs')], + to: [path.join('node_modules', 'big.js', 'big.mjs')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'big.js', 'LICENSE.md')], + to: [path.join('node_modules', 'big.js', 'LICENSE.md')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'big.js', 'package.json')], + to: [path.join('node_modules', 'big.js', 'package.json')], + }, + }), + copy({ + assets: { + from: [path.join('node_modules', 'node-fetch', '**', '*')], + to: [path.join('node_modules', 'node-fetch')], + }, + }), copyFolderFiles({ fromPath: __dirname, targetFolderPath: RELEASE_FOLDER_PATH, diff --git a/package-lock.json b/package-lock.json index 1572992..2770fc0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@google-cloud/bigquery": "8.0.0", "@hackolade/sql-select-statement-parser": "0.0.20", + "big.js": "6.2.2", "fs-extra": "11.3.0", "lodash": "4.17.21" }, diff --git a/package.json b/package.json index 71c64d0..82d17f5 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "dependencies": { "@google-cloud/bigquery": "8.0.0", "@hackolade/sql-select-statement-parser": "0.0.20", + "big.js": "6.2.2", "fs-extra": "11.3.0", "lodash": "4.17.21" }, From af6cf667e6cefd6b5f0cdf9fe630a9e00b64b203 Mon Sep 17 00:00:00 2001 From: hackolade-bot Date: Thu, 29 May 2025 16:52:42 +0300 Subject: [PATCH 2/5] Make sure that node_modules are not bundled --- buildConstants.js | 1 - esbuild.package.js | 70 +++------------------ package-lock.json | 148 +++++---------------------------------------- package.json | 2 +- 4 files changed, 25 insertions(+), 196 deletions(-) diff --git a/buildConstants.js b/buildConstants.js index 5c3f239..87efbcc 100644 --- a/buildConstants.js +++ b/buildConstants.js @@ -19,7 +19,6 @@ const EXCLUDED_FILES = [ 'build', 'release', 'node_modules', - 'package-lock.json', ]; module.exports = { diff --git a/esbuild.package.js b/esbuild.package.js index 07669e8..571acaf 100644 --- a/esbuild.package.js +++ b/esbuild.package.js @@ -1,10 +1,12 @@ const fs = require('fs'); const path = require('path'); const esbuild = require('esbuild'); +const util = require('util'); +const exec = util.promisify(require('child_process').exec); const { clean } = require('esbuild-plugin-clean'); -const { copy } = require('esbuild-plugin-copy'); const { copyFolderFiles, addReleaseFlag } = require('@hackolade/hck-esbuild-plugins-pack'); const { EXCLUDED_EXTENSIONS, EXCLUDED_FILES, DEFAULT_RELEASE_FOLDER_PATH } = require('./buildConstants'); +const { nodeExternalsPlugin } = require('esbuild-node-externals'); const packageData = JSON.parse(fs.readFileSync('./package.json').toString()); const RELEASE_FOLDER_PATH = path.join(DEFAULT_RELEASE_FOLDER_PATH, `${packageData.name}-${packageData.version}`); @@ -40,66 +42,7 @@ esbuild clean({ patterns: [DEFAULT_RELEASE_FOLDER_PATH], }), - copy({ - assets: { - from: [path.join('node_modules', 'lodash', '**', '*')], - to: [path.join('node_modules', 'lodash')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'debug', '**', '*')], - to: [path.join('node_modules', 'debug')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'http-proxy-agent', '**', '*')], - to: [path.join('node_modules', 'http-proxy-agent')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'https-proxy-agent', '**', '*')], - to: [path.join('node_modules', 'https-proxy-agent')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'fs-extra', '**', '*')], - to: [path.join('node_modules', 'fs-extra')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'big.js', 'big.js')], - to: [path.join('node_modules', 'big.js', 'big.js')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'big.js', 'big.mjs')], - to: [path.join('node_modules', 'big.js', 'big.mjs')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'big.js', 'LICENSE.md')], - to: [path.join('node_modules', 'big.js', 'LICENSE.md')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'big.js', 'package.json')], - to: [path.join('node_modules', 'big.js', 'package.json')], - }, - }), - copy({ - assets: { - from: [path.join('node_modules', 'node-fetch', '**', '*')], - to: [path.join('node_modules', 'node-fetch')], - }, - }), + nodeExternalsPlugin(), copyFolderFiles({ fromPath: __dirname, targetFolderPath: RELEASE_FOLDER_PATH, @@ -109,4 +52,9 @@ esbuild addReleaseFlag(path.resolve(RELEASE_FOLDER_PATH, 'package.json')), ], }) + .then(async () => { + const { stdout, stderr } = await exec(`npm ci --omit=dev`, { cwd: RELEASE_FOLDER_PATH }); + console.log('stdout:', stdout); + console.log('stderr:', stderr); + }) .catch(() => process.exit(1)); diff --git a/package-lock.json b/package-lock.json index 2770fc0..d5d0f1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,8 +20,8 @@ "@typescript-eslint/eslint-plugin": "7.11.0", "@typescript-eslint/parser": "7.11.0", "esbuild": "0.20.2", + "esbuild-node-externals": "1.18.0", "esbuild-plugin-clean": "1.0.1", - "esbuild-plugin-copy": "2.1.1", "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", "eslint-formatter-teamcity": "^1.0.0", @@ -1248,20 +1248,6 @@ "node": ">=14" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1492,19 +1478,6 @@ "node": "*" } }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -1610,31 +1583,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -2160,51 +2108,36 @@ "@esbuild/win32-x64": "0.20.2" } }, - "node_modules/esbuild-plugin-clean": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esbuild-plugin-clean/-/esbuild-plugin-clean-1.0.1.tgz", - "integrity": "sha512-ul606g0wX6oeobBgi3EqpZtCBCwNwCDivvnshsNS5pUsRylKoxUnDqK0ZIyPinlMbP6s8Opc9y2zOeY1Plhe8Q==", + "node_modules/esbuild-node-externals": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/esbuild-node-externals/-/esbuild-node-externals-1.18.0.tgz", + "integrity": "sha512-suFVX3SzZlXrGIS9Yqx+ZaHL4w1p0e/j7dQbOM9zk8SfFpnAGnDplHUKXIf9kcPEAfZRL66JuYeVSVlsSEQ5Eg==", "dev": true, "license": "MIT", "dependencies": { - "chalk": "^4.1.2", - "del": "^6.0.0" + "find-up": "^5.0.0" + }, + "engines": { + "node": ">=12" }, "peerDependencies": { - "esbuild": ">= 0.14.0" + "esbuild": "0.12 - 0.25" } }, - "node_modules/esbuild-plugin-copy": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/esbuild-plugin-copy/-/esbuild-plugin-copy-2.1.1.tgz", - "integrity": "sha512-Bk66jpevTcV8KMFzZI1P7MZKZ+uDcrZm2G2egZ2jNIvVnivDpodZI+/KnpL3Jnap0PBdIHU7HwFGB8r+vV5CVw==", + "node_modules/esbuild-plugin-clean": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esbuild-plugin-clean/-/esbuild-plugin-clean-1.0.1.tgz", + "integrity": "sha512-ul606g0wX6oeobBgi3EqpZtCBCwNwCDivvnshsNS5pUsRylKoxUnDqK0ZIyPinlMbP6s8Opc9y2zOeY1Plhe8Q==", "dev": true, "license": "MIT", "dependencies": { "chalk": "^4.1.2", - "chokidar": "^3.5.3", - "fs-extra": "^10.0.1", - "globby": "^11.0.3" + "del": "^6.0.0" }, "peerDependencies": { "esbuild": ">= 0.14.0" } }, - "node_modules/esbuild-plugin-copy/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -2871,21 +2804,6 @@ "dev": true, "license": "ISC" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -3499,19 +3417,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/is-boolean-object": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", @@ -4316,16 +4221,6 @@ "@smithy/types": "3.6.0" } }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/npm-run-path": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", @@ -4731,19 +4626,6 @@ "node": ">= 6" } }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", diff --git a/package.json b/package.json index 82d17f5..0ab27c3 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "@typescript-eslint/eslint-plugin": "7.11.0", "@typescript-eslint/parser": "7.11.0", "esbuild": "0.20.2", + "esbuild-node-externals": "1.18.0", "esbuild-plugin-clean": "1.0.1", - "esbuild-plugin-copy": "2.1.1", "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", "eslint-formatter-teamcity": "^1.0.0", From 6d9c2c219d0db0962bac93e3b4281e8497539290 Mon Sep 17 00:00:00 2001 From: hackolade-bot Date: Thu, 29 May 2025 16:53:57 +0300 Subject: [PATCH 3/5] remove redundand externals --- esbuild.package.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/esbuild.package.js b/esbuild.package.js index 571acaf..00652a3 100644 --- a/esbuild.package.js +++ b/esbuild.package.js @@ -28,16 +28,6 @@ esbuild outdir: RELEASE_FOLDER_PATH, minify: true, logLevel: 'info', - external: [ - 'electron', - 'lodash', - 'debug', - 'https-proxy-agent', - 'http-proxy-agent', - 'fs-extra', - 'big.js', - 'node-fetch', - ], plugins: [ clean({ patterns: [DEFAULT_RELEASE_FOLDER_PATH], From efea8a4ab0a290039e89521cb1d5e513ec407c4f Mon Sep 17 00:00:00 2001 From: hackolade-bot Date: Fri, 30 May 2025 10:08:43 +0300 Subject: [PATCH 4/5] Remove .sonarlint from plugin build --- buildConstants.js | 1 + 1 file changed, 1 insertion(+) diff --git a/buildConstants.js b/buildConstants.js index 87efbcc..14dbf37 100644 --- a/buildConstants.js +++ b/buildConstants.js @@ -16,6 +16,7 @@ const EXCLUDED_FILES = [ '.prettierignore', '.prettierrc', '.dockerignore', + '.sonarlint', 'build', 'release', 'node_modules', From 9e86efcc40f0d49dd8ec6805fea79780f97c0efd Mon Sep 17 00:00:00 2001 From: hackolade-bot Date: Fri, 30 May 2025 13:21:21 +0300 Subject: [PATCH 5/5] Add ignored files --- buildConstants.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildConstants.js b/buildConstants.js index 14dbf37..54853c1 100644 --- a/buildConstants.js +++ b/buildConstants.js @@ -17,6 +17,9 @@ const EXCLUDED_FILES = [ '.prettierrc', '.dockerignore', '.sonarlint', + '.sonarcloud.properties', + '.npmrc', + 'tsconfig.json', 'build', 'release', 'node_modules',