From 713e86e8779b46ac529ed2052c4349f4e6ef1be1 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Fri, 26 Aug 2022 12:33:29 -0700 Subject: [PATCH] Update rollup script to exclude new secp256k1 and hmac/sha256 dependencies (#27428) * fix: repair build script, not to bundle @noble libraries but to keep them as external deps * chore: remove secp256k1 Typescript types --- web3.js/package-lock.json | 27 ++++++++------------------- web3.js/package.json | 1 - web3.js/rollup.config.js | 13 ++++++------- web3.js/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/web3.js/package-lock.json b/web3.js/package-lock.json index 0d15fe154..77e6efd5a 100644 --- a/web3.js/package-lock.json +++ b/web3.js/package-lock.json @@ -52,7 +52,6 @@ "@types/mz": "^2.7.3", "@types/node": "^17.0.24", "@types/node-fetch": "2", - "@types/secp256k1": "^4.0.1", "@types/sinon": "^10.0.0", "@types/sinon-chai": "^3.2.8", "@typescript-eslint/eslint-plugin": "^4.14.2", @@ -3741,15 +3740,6 @@ "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==", "dev": true }, - "node_modules/@types/secp256k1": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz", - "integrity": "sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/sinon": { "version": "10.0.11", "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.11.tgz", @@ -10822,6 +10812,8 @@ }, "node_modules/npm/node_modules/debug/node_modules/ms": { "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true, "inBundle": true, "license": "MIT" @@ -12396,6 +12388,8 @@ }, "node_modules/npm/node_modules/semver/node_modules/lru-cache": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "inBundle": true, "license": "ISC", @@ -19382,15 +19376,6 @@ "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==", "dev": true }, - "@types/secp256k1": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz", - "integrity": "sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/sinon": { "version": "10.0.11", "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.11.tgz", @@ -24660,6 +24645,8 @@ "dependencies": { "ms": { "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "bundled": true, "dev": true } @@ -25831,6 +25818,8 @@ "dependencies": { "lru-cache": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "bundled": true, "dev": true, "requires": { diff --git a/web3.js/package.json b/web3.js/package.json index fadd5e81b..24d964c30 100644 --- a/web3.js/package.json +++ b/web3.js/package.json @@ -100,7 +100,6 @@ "@types/mz": "^2.7.3", "@types/node": "^17.0.24", "@types/node-fetch": "2", - "@types/secp256k1": "^4.0.1", "@types/sinon": "^10.0.0", "@types/sinon-chai": "^3.2.8", "@typescript-eslint/eslint-plugin": "^4.14.2", diff --git a/web3.js/rollup.config.js b/web3.js/rollup.config.js index b8ba8ec90..23ecc5424 100644 --- a/web3.js/rollup.config.js +++ b/web3.js/rollup.config.js @@ -95,6 +95,9 @@ function generateConfig(configType, format) { // Prevent dependencies from being bundled config.external = [ /@babel\/runtime/, + '@noble/hashes/hmac', + '@noble/hashes/sha256', + '@noble/secp256k1', '@solana/buffer-layout', 'bigint-buffer', 'bn.js', @@ -106,7 +109,6 @@ function generateConfig(configType, format) { 'js-sha3', 'node-fetch', 'rpc-websockets', - 'secp256k1', 'superstruct', 'tweetnacl', ]; @@ -159,6 +161,9 @@ function generateConfig(configType, format) { config.external = [ /@babel\/runtime/, '@solana/buffer-layout', + '@noble/hashes/hmac', + '@noble/hashes/sha256', + '@noble/secp256k1', 'bigint-buffer', 'bn.js', 'borsh', @@ -172,7 +177,6 @@ function generateConfig(configType, format) { 'node-fetch', 'react-native-url-polyfill', 'rpc-websockets', - 'secp256k1', 'superstruct', 'tweetnacl', ]; @@ -180,11 +184,6 @@ function generateConfig(configType, format) { break; } } - - // TODO: Find a workaround to avoid resolving the following JSON file: - // `node_modules/secp256k1/node_modules/elliptic/package.json` - config.plugins.push(json()); - break; case 'node': config.output = [ diff --git a/web3.js/yarn.lock b/web3.js/yarn.lock index a83b4fe45..469808960 100644 --- a/web3.js/yarn.lock +++ b/web3.js/yarn.lock @@ -1347,12 +1347,12 @@ "@noble/hashes@^1.1.2": version "1.1.2" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183" + resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz" integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA== "@noble/secp256k1@^1.6.3": version "1.6.3" - resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.6.3.tgz#7eed12d9f4404b416999d0c87686836c4c5c9b94" + resolved "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.6.3.tgz" integrity sha512-T04e4iTurVy7I8Sw4+c5OSN9/RkPlo1uKxAomtxQNLq8j1uPAqnsqG1bqvY3Jv7c13gyr6dui0zmh/I3+f/JaQ== "@nodelib/fs.scandir@2.1.5": @@ -2084,13 +2084,6 @@ resolved "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz" integrity sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g== -"@types/secp256k1@^4.0.1": - version "4.0.3" - resolved "https://registry.npmjs.org/@types/secp256k1/-/secp256k1-4.0.3.tgz" - integrity sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w== - dependencies: - "@types/node" "*" - "@types/sinon-chai@^3.2.8": version "3.2.8" resolved "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-3.2.8.tgz" @@ -8365,19 +8358,26 @@ unique-filename@^1.1.1: unique-slug "^2.0.0" unique-filename@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-2.0.0.tgz#c844c84c3b22e92038b0c53950f9dc34d2b55490" - integrity sha512-tpzoz2RpZ//6Zt4GPpOFTyrnfZuSvjIfe8lvx6Thp4yTQwJtAFwPlssEBE62VhGA2We5/COyNpcIu+OABu3/Yg== + version "2.0.1" + resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-2.0.1.tgz#e785f8675a9a7589e0ac77e0b5c34d2eaeac6da2" + integrity sha512-ODWHtkkdx3IAR+veKxFV+VBkUMcN+FaqzUUd7IZzt+0zhDZFPFxhlqwPF3YQvMHx1TD0tdgYl+kuPnJ8E6ql7A== dependencies: - unique-slug "^2.0.2" + unique-slug "^3.0.0" -unique-slug@^2.0.0, unique-slug@^2.0.2: +unique-slug@^2.0.0: version "2.0.2" - resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-2.0.2.tgz#baabce91083fc64e945b0f3ad613e264f7cd4e6c" + resolved "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz" integrity sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w== dependencies: imurmurhash "^0.1.4" +unique-slug@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-3.0.0.tgz#6d347cf57c8a7a7a6044aabd0e2d74e4d76dc7c9" + integrity sha512-8EyMynh679x/0gqE9fT9oilG+qEt+ibFyqjuVTsZn1+CMxH+XLlpvr2UZx4nVcCwTpx81nICr2JQFkM+HPLq4w== + dependencies: + imurmurhash "^0.1.4" + unique-string@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz"