diff --git a/.babel.config.js b/.babel.config.js index 5716478ee..e2d5ae96a 100644 --- a/.babel.config.js +++ b/.babel.config.js @@ -22,7 +22,8 @@ module.exports = { ['@babel/preset-typescript'] ], plugins: [ - "add-module-exports", + 'lodash', + 'add-module-exports', ['@babel/plugin-transform-runtime', { corejs: 3, helpers: true, diff --git a/package-lock.json b/package-lock.json index 8f7c8e51b..2faf90e90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3507,6 +3507,19 @@ "@types/babel__traverse": "^7.0.6" } }, + "babel-plugin-lodash": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/babel-plugin-lodash/-/babel-plugin-lodash-3.3.4.tgz", + "integrity": "sha512-yDZLjK7TCkWl1gpBeBGmuaDIFhZKmkoL+Cu2MUUjv5VxUZx/z7tBGBCBcQs5RI1Bkz5LLmNdjx7paOyQtMovyg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0-beta.49", + "@babel/types": "^7.0.0-beta.49", + "glob": "^7.1.1", + "lodash": "^4.17.10", + "require-package-name": "^2.0.1" + } + }, "babel-plugin-polyfill-corejs2": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.1.5.tgz", @@ -9425,8 +9438,16 @@ "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lodash-webpack-plugin": { + "version": "0.11.6", + "resolved": "https://registry.npmjs.org/lodash-webpack-plugin/-/lodash-webpack-plugin-0.11.6.tgz", + "integrity": "sha512-nsHN/+IxZK/C425vGC8pAxkKJ8KQH2+NJnhDul14zYNWr6HJcA95w+oRR7Cp0oZpOdMplDZXmjVROp8prPk7ig==", + "dev": true, + "requires": { + "lodash": "^4.17.20" + } }, "lodash._arraycopy": { "version": "3.0.0", @@ -9520,12 +9541,8 @@ "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" - }, - "lodash.has": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz", - "integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=" + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true }, "lodash.isarguments": { "version": "3.1.0", @@ -9556,22 +9573,12 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, - "lodash.set": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", - "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=" - }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "dev": true }, - "lodash.uniqueid": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.uniqueid/-/lodash.uniqueid-4.0.1.tgz", - "integrity": "sha1-MmjyanyI5PSxdY1nknGBTjH6WyY=" - }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -11790,6 +11797,12 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "require-package-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/require-package-name/-/require-package-name-2.0.1.tgz", + "integrity": "sha1-wR6XJ2tluOKSP3Xav1+y7ww4Qbk=", + "dev": true + }, "resolve": { "version": "1.20.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", diff --git a/package.json b/package.json index 543ac854a..84ae61f23 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "@typescript-eslint/parser": "^4.17.0", "babel-loader": "^8.2.2", "babel-plugin-add-module-exports": "^1.0.4", + "babel-plugin-lodash": "^3.3.4", "babel-plugin-transform-class-properties": "^6.24.1", "benchmark": "^2.1.4", "buffer": "^6.0.3", @@ -106,6 +107,7 @@ "git-revision-webpack-plugin": "^3.0.6", "jest": "^26.6.3", "jest-circus": "^26.6.3", + "lodash-webpack-plugin": "^0.11.6", "nightwatch": "^1.5.1", "process": "^0.11.10", "sinon": "^9.2.4", @@ -138,10 +140,7 @@ "@ethersproject/web": "^5.0.13", "debug": "^4.3.2", "eventemitter3": "^4.0.7", - "lodash.uniqueid": "^4.0.1", - "lodash.has": "^4.0.1", - "lodash.get": "^4.0.1", - "lodash.set": "^4.0.1", + "lodash": "^4.17.21", "mem": "^8.0.0", "node-abort-controller": "^1.1.0", "node-fetch": "^2.6.1", diff --git a/src/Config.ts b/src/Config.ts index fe777acc3..7f156ac27 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -11,8 +11,8 @@ import { ConnectionInfo } from '@ethersproject/web' import { EthereumAddress, Todo } from './types' import { BytesLike } from '@ethersproject/bytes' import { isAddress } from '@ethersproject/address' -import has from 'lodash.has' -import get from 'lodash.get' +import has from 'lodash/has' +import get from 'lodash/get' export type EthereumConfig = ExternalProvider|JsonRpcFetchFunc diff --git a/src/utils/index.ts b/src/utils/index.ts index a0788f679..008a0fe0c 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -2,7 +2,7 @@ import { inspect } from 'util' import EventEmitter from 'events' import { v4 as uuidv4 } from 'uuid' -import uniqueId from 'lodash.uniqueid' +import uniqueId from 'lodash/uniqueId' import pMemoize from 'p-memoize' import pLimit from 'p-limit' import mem from 'mem' diff --git a/test/unit/Config.test.ts b/test/unit/Config.test.ts index 49cbe4866..f658fdaaf 100644 --- a/test/unit/Config.test.ts +++ b/test/unit/Config.test.ts @@ -1,9 +1,9 @@ +import set from 'lodash/set' import { arrayify, BytesLike } from '@ethersproject/bytes' + import { StreamrClient } from '../../src/StreamrClient' -import set from 'lodash.set' describe('Config', () => { - describe('validate ethereum addresses', () => { const createClient = (propertyPaths: string, value: string|undefined|null) => { const opts: any = {} diff --git a/webpack.config.js b/webpack.config.js index c4952a461..2f46fa51a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,6 +7,7 @@ const path = require('path') const webpack = require('webpack') const TerserPlugin = require('terser-webpack-plugin') +const LodashWebpackPlugin = require('lodash-webpack-plugin') const { merge } = require('webpack-merge') const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') const GitRevisionPlugin = require('git-revision-webpack-plugin') @@ -105,6 +106,7 @@ module.exports = (env, argv) => { } }, plugins: [ + new LodashWebpackPlugin(), new webpack.ProvidePlugin({ process: 'process/browser', Buffer: ['buffer', 'Buffer'],