From 838a2774999ea9bede5f1f6d06df5c6054f50dd9 Mon Sep 17 00:00:00 2001 From: Edward Alvarado Date: Sat, 16 Sep 2023 18:32:07 -0300 Subject: [PATCH] fix for web-ui (#219) Co-authored-by: Edward Alvarado --- engine/package-lock.json | 118 +++++++------------------ engine/paima-mw-core/esbuildconfig.cjs | 12 +-- engine/paima-mw-core/package.json | 13 ++- 3 files changed, 38 insertions(+), 105 deletions(-) diff --git a/engine/package-lock.json b/engine/package-lock.json index feb7f3a38..718b63df5 100644 --- a/engine/package-lock.json +++ b/engine/package-lock.json @@ -1817,40 +1817,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@esbuild-plugins/node-globals-polyfill": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-globals-polyfill/-/node-globals-polyfill-0.2.3.tgz", - "integrity": "sha512-r3MIryXDeXDOZh7ih1l/yE9ZLORCd5e8vWg02azWRGj5SPTuoh69A2AIyn0Z31V/kHBfZ4HgWJ+OK3GTTwLmnw==", - "dev": true, - "peerDependencies": { - "esbuild": "*" - } - }, - "node_modules/@esbuild-plugins/node-modules-polyfill": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@esbuild-plugins/node-modules-polyfill/-/node-modules-polyfill-0.2.2.tgz", - "integrity": "sha512-LXV7QsWJxRuMYvKbiznh+U1ilIop3g2TeKRzUxOG5X3YITc8JyyTa90BmLwqqv0YnX4v32CSlG+vsziZp9dMvA==", - "dev": true, - "dependencies": { - "escape-string-regexp": "^4.0.0", - "rollup-plugin-node-polyfills": "^0.2.1" - }, - "peerDependencies": { - "esbuild": "*" - } - }, - "node_modules/@esbuild-plugins/node-modules-polyfill/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@esbuild/android-arm": { "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", @@ -3657,6 +3623,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@jspm/core": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@jspm/core/-/core-2.0.1.tgz", + "integrity": "sha512-Lg3PnLp0QXpxwLIAuuJboLeRaIhrgJjeuh797QADg3xz8wGLugQOS5DpsE8A6i6Adgzf+bacllkKZG3J0tGfDw==", + "dev": true + }, "node_modules/@metamask/eth-sig-util": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz", @@ -10060,6 +10032,19 @@ "node": ">=8" } }, + "node_modules/esbuild-plugin-polyfill-node": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/esbuild-plugin-polyfill-node/-/esbuild-plugin-polyfill-node-0.3.0.tgz", + "integrity": "sha512-SHG6CKUfWfYyYXGpW143NEZtcVVn8S/WHcEOxk62LuDXnY4Zpmc+WmxJKN6GMTgTClXJXhEM5KQlxKY6YjbucQ==", + "dev": true, + "dependencies": { + "@jspm/core": "^2.0.1", + "import-meta-resolve": "^3.0.0" + }, + "peerDependencies": { + "esbuild": "*" + } + }, "node_modules/esbuild-sunos-64": { "version": "0.14.54", "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.54.tgz", @@ -10412,12 +10397,6 @@ "node": ">=4.0" } }, - "node_modules/estree-walker": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", - "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", - "dev": true - }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -11982,6 +11961,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/import-meta-resolve": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-3.0.0.tgz", + "integrity": "sha512-4IwhLhNNA8yy445rPjD/lWh++7hMDOml2eHtd58eG7h+qK3EryMuuRbsHGPikCoAgIkkDnckKfWSk2iDla/ejg==", + "dev": true, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -14691,15 +14680,6 @@ "resolved": "https://registry.npmjs.org/ltgt/-/ltgt-2.2.1.tgz", "integrity": "sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA==" }, - "node_modules/magic-string": { - "version": "0.25.9", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", - "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", - "dev": true, - "dependencies": { - "sourcemap-codec": "^1.4.8" - } - }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -20503,36 +20483,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/rollup-plugin-inject": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-inject/-/rollup-plugin-inject-3.0.2.tgz", - "integrity": "sha512-ptg9PQwzs3orn4jkgXJ74bfs5vYz1NCZlSQMBUA0wKcGp5i5pA1AO3fOUEte8enhGUC+iapTCzEWw2jEFFUO/w==", - "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.", - "dev": true, - "dependencies": { - "estree-walker": "^0.6.1", - "magic-string": "^0.25.3", - "rollup-pluginutils": "^2.8.1" - } - }, - "node_modules/rollup-plugin-node-polyfills": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-polyfills/-/rollup-plugin-node-polyfills-0.2.1.tgz", - "integrity": "sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA==", - "dev": true, - "dependencies": { - "rollup-plugin-inject": "^3.0.0" - } - }, - "node_modules/rollup-pluginutils": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", - "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", - "dev": true, - "dependencies": { - "estree-walker": "^0.6.1" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -20887,13 +20837,6 @@ "source-map": "^0.6.0" } }, - "node_modules/sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "deprecated": "Please use @jridgewell/sourcemap-codec instead", - "dev": true - }, "node_modules/split-on-first": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", @@ -24663,11 +24606,10 @@ "bech32": "^2.0.0" }, "devDependencies": { - "@esbuild-plugins/node-globals-polyfill": "^0.2.3", - "@esbuild-plugins/node-modules-polyfill": "^0.2.2", "dotenv": "^16.0.3", "esbuild": "^0.17.14", "esbuild-plugin-d.ts": "^1.1.0", + "esbuild-plugin-polyfill-node": "^0.3.0", "prettier": "^3.0.3", "prettier-plugin-organize-imports": "^3.2.3", "typescript": "^4.7.4" diff --git a/engine/paima-mw-core/esbuildconfig.cjs b/engine/paima-mw-core/esbuildconfig.cjs index 56edc5f74..b443839fb 100644 --- a/engine/paima-mw-core/esbuildconfig.cjs +++ b/engine/paima-mw-core/esbuildconfig.cjs @@ -1,8 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const esbuild = require('esbuild'); -const g = require('@esbuild-plugins/node-globals-polyfill'); -const m = require('@esbuild-plugins/node-modules-polyfill'); -const modules = m.NodeModulesPolyfillPlugin(); +const { polyfillNode } = require('esbuild-plugin-polyfill-node'); const define = { global: 'window' }; @@ -21,12 +19,6 @@ if ( throw new Error('Please ensure you have filled out your .env file'); } -const global = g.NodeGlobalsPolyfillPlugin({ - process: true, - buffer: true, - define: { 'process.env.var': '"hello"' }, // inject will override define, to keep env vars you must also pass define here https://github.com/evanw/esbuild/issues/660 -}); - const config = { entryPoints: ['build/index.js'], bundle: true, @@ -34,7 +26,7 @@ const config = { globalName: 'middleware', define, outfile: 'web/middleware.js', - plugins: [global, modules], + plugins: [polyfillNode({})], external: ['pg-native'], }; diff --git a/engine/paima-mw-core/package.json b/engine/paima-mw-core/package.json index d7ccb24c4..f52a6e71a 100644 --- a/engine/paima-mw-core/package.json +++ b/engine/paima-mw-core/package.json @@ -17,25 +17,24 @@ }, "author": "", "devDependencies": { - "@esbuild-plugins/node-globals-polyfill": "^0.2.3", - "@esbuild-plugins/node-modules-polyfill": "^0.2.2", "dotenv": "^16.0.3", "esbuild": "^0.17.14", "esbuild-plugin-d.ts": "^1.1.0", + "esbuild-plugin-polyfill-node": "^0.3.0", "prettier": "^3.0.3", "prettier-plugin-organize-imports": "^3.2.3", "typescript": "^4.7.4" }, "dependencies": { "@metamask/providers": "^10.2.1", + "@paima/concise": "1.0.0", + "@paima/crypto": "1.0.0", + "@paima/prando": "1.0.0", + "@paima/providers": "1.0.0", "@perawallet/connect": "^1.2.3", "@polkadot/extension-dapp": "^0.44.9", "@truffle/hdwallet-provider": "^2.1.14", "algosdk": "^2.3.0", - "bech32": "^2.0.0", - "@paima/concise": "1.0.0", - "@paima/crypto": "1.0.0", - "@paima/prando": "1.0.0", - "@paima/providers": "1.0.0" + "bech32": "^2.0.0" } }